Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-01 00:41:11
Exec Total Coverage
Lines: 1315 3883 33.9%
Functions: 113 335 33.7%
Branches: 603 2734 22.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 11 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte disable_direct_updating;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 byte epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
11 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271
272 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
273 {
274 return D_O_K;
275 }
276
277 11 void load_game_configs()
278 {
279 //set_config_file("zc.cfg"); //shift back when done
280 //load the module
281 11 strcpy(moduledata.module_name,get_config_string("ZCMODULE",qst_module_name,"classic.zmod"));
282 11 joystick_index = zc_get_config(cfg_sect,"joystick_index",0);
283 11 js_stick_1_x_stick = zc_get_config(cfg_sect,"js_stick_1_x_stick",0);
284 11 js_stick_1_x_axis = zc_get_config(cfg_sect,"js_stick_1_x_axis",0);
285 11 js_stick_1_x_offset = zc_get_config(cfg_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 11 js_stick_1_y_stick = zc_get_config(cfg_sect,"js_stick_1_y_stick",0);
287 11 js_stick_1_y_axis = zc_get_config(cfg_sect,"js_stick_1_y_axis",1);
288 11 js_stick_1_y_offset = zc_get_config(cfg_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 11 js_stick_2_x_stick = zc_get_config(cfg_sect,"js_stick_2_x_stick",1);
290 11 js_stick_2_x_axis = zc_get_config(cfg_sect,"js_stick_2_x_axis",0);
291 11 js_stick_2_x_offset = zc_get_config(cfg_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 11 js_stick_2_y_stick = zc_get_config(cfg_sect,"js_stick_2_y_stick",1);
293 11 js_stick_2_y_axis = zc_get_config(cfg_sect,"js_stick_2_y_axis",1);
294 11 js_stick_2_y_offset = zc_get_config(cfg_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 11 analog_movement = (zc_get_config(cfg_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 11 cheat_modifier_keys[0] = zc_get_config(cfg_sect,"key_cheatmod_a1",KEY_LSHIFT);
299 11 cheat_modifier_keys[1] = zc_get_config(cfg_sect,"key_cheatmod_a2",0);
300 11 cheat_modifier_keys[2] = zc_get_config(cfg_sect,"key_cheatmod_b1",KEY_RSHIFT);
301 11 cheat_modifier_keys[3] = zc_get_config(cfg_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 11 Akey = zc_get_config(cfg_sect,"key_a",KEY_ALT);
307 11 Bkey = zc_get_config(cfg_sect,"key_b",KEY_ZC_LCONTROL);
308 11 Skey = zc_get_config(cfg_sect,"key_s",KEY_ENTER);
309 11 Lkey = zc_get_config(cfg_sect,"key_l",KEY_Z);
310 11 Rkey = zc_get_config(cfg_sect,"key_r",KEY_X);
311 11 Pkey = zc_get_config(cfg_sect,"key_p",KEY_SPACE);
312 11 Exkey1 = zc_get_config(cfg_sect,"key_ex1",KEY_Q);
313 11 Exkey2 = zc_get_config(cfg_sect,"key_ex2",KEY_W);
314 11 Exkey3 = zc_get_config(cfg_sect,"key_ex3",KEY_A);
315 11 Exkey4 = zc_get_config(cfg_sect,"key_ex4",KEY_S);
316
317 11 DUkey = zc_get_config(cfg_sect,"key_up", KEY_UP);
318 11 DDkey = zc_get_config(cfg_sect,"key_down", KEY_DOWN);
319 11 DLkey = zc_get_config(cfg_sect,"key_left", KEY_LEFT);
320 11 DRkey = zc_get_config(cfg_sect,"key_right",KEY_RIGHT);
321
322 11 Abtn = zc_get_config(cfg_sect,"btn_a",2);
323 11 Bbtn = zc_get_config(cfg_sect,"btn_b",1);
324 11 Sbtn = zc_get_config(cfg_sect,"btn_s",10);
325 11 Mbtn = zc_get_config(cfg_sect,"btn_m",9);
326 11 Lbtn = zc_get_config(cfg_sect,"btn_l",5);
327 11 Rbtn = zc_get_config(cfg_sect,"btn_r",6);
328 11 Pbtn = zc_get_config(cfg_sect,"btn_p",12);
329 11 Exbtn1 = zc_get_config(cfg_sect,"btn_ex1",7);
330 11 Exbtn2 = zc_get_config(cfg_sect,"btn_ex2",8);
331 11 Exbtn3 = zc_get_config(cfg_sect,"btn_ex3",4);
332 11 Exbtn4 = zc_get_config(cfg_sect,"btn_ex4",3);
333
334 11 DUbtn = zc_get_config(cfg_sect,"btn_up",13);
335 11 DDbtn = zc_get_config(cfg_sect,"btn_down",14);
336 11 DLbtn = zc_get_config(cfg_sect,"btn_left",15);
337 11 DRbtn = zc_get_config(cfg_sect,"btn_right",16);
338
339 11 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 11 digi_volume = zc_get_config(cfg_sect,"digi",248);
342 11 midi_volume = zc_get_config(cfg_sect,"midi",255);
343 11 sfx_volume = zc_get_config(cfg_sect,"sfx",248);
344 11 emusic_volume = zc_get_config(cfg_sect,"emusic",248);
345 11 pan_style = zc_get_config(cfg_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 11 zcmusic_bufsz = vbound(zc_get_config(cfg_sect,"zcmusic_bufsz",64),1,128);
348 11 volkeys = zc_get_config(cfg_sect,"volkeys",0)!=0;
349 11 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 11 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 11 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 11 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 11 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 11 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 11 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 11 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 11 title_version = zc_get_config(cfg_sect,"title",2);
361 11 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 11 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 11 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 11 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 11 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 11 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 11 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 11 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 11 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 //workaround for the 100% CPU bug. -Gleeok
378 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
379 11 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
380 #else
381 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
382 #endif
383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 frame_rest_suggest = zc_min(2, frame_rest_suggest);
384
385 11 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
386
387 #ifdef _WIN32
388 use_debug_console = (byte) zc_get_config(cfg_sect,"debug_console",0);
389 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
390 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
391 console_on_top = (byte) zc_get_config("CONSOLE","console_on_top",0);
392 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
393 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
394
395 // This seems to fix some problems on Windows 7
396 disable_direct_updating = (byte) zc_get_config("graphics","disable_direct_updating",1);
397
398 // This one's for Aero
399 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
400
401 // And this one fixes patches unloading on some MIDI setups
402 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
403 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
404 #else //UNIX
405 11 use_debug_console = false;//(byte) zc_get_config(cfg_sect,"debug_console",0);
406 11 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
407 11 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
408 11 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
409 #endif
410
411 11 char const* default_path = "";
412 11 strcpy(qstdir,get_config_string(cfg_sect,qst_dir_name,default_path));
413
414
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(strlen(qstdir)==0)
415 {
416 1 getcwd(qstdir,2048);
417 1 fix_filename_case(qstdir);
418 1 fix_filename_slashes(qstdir);
419 1 put_backslash(qstdir);
420 1 }
421 else
422 {
423 10 chop_path(qstdir);
424 }
425
426 11 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
427 11 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
428 11 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
429 11 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
430 11 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
431 11 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
432 11 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
433 11 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
434 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
435 11 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
436 11 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
437 11 }
438
439 11 void save_game_configs()
440 {
441 11 packfile_password("");
442
443 11 set_config_string("ZCMODULE",qst_module_name,moduledata.module_name);
444
445 11 set_config_int(cfg_sect,"joystick_index",joystick_index);
446 11 set_config_int(cfg_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
447 11 set_config_int(cfg_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
448 11 set_config_int(cfg_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
449 11 set_config_int(cfg_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
450 11 set_config_int(cfg_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
451 11 set_config_int(cfg_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
452 11 set_config_int(cfg_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
453 11 set_config_int(cfg_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
454 11 set_config_int(cfg_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
455 11 set_config_int(cfg_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
456 11 set_config_int(cfg_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
457 11 set_config_int(cfg_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
458 11 set_config_int(cfg_sect,"analog_movement",analog_movement);
459
460 //cheat modifier keya
461
462 11 set_config_int(cfg_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
463 11 set_config_int(cfg_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
464 11 set_config_int(cfg_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
465 11 set_config_int(cfg_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!replay_is_replaying())
468 {
469 11 set_config_int(cfg_sect,"key_a",Akey);
470 11 set_config_int(cfg_sect,"key_b",Bkey);
471 11 set_config_int(cfg_sect,"key_s",Skey);
472 11 set_config_int(cfg_sect,"key_l",Lkey);
473 11 set_config_int(cfg_sect,"key_r",Rkey);
474 11 set_config_int(cfg_sect,"key_p",Pkey);
475 11 set_config_int(cfg_sect,"key_ex1",Exkey1);
476 11 set_config_int(cfg_sect,"key_ex2",Exkey2);
477 11 set_config_int(cfg_sect,"key_ex3",Exkey3);
478 11 set_config_int(cfg_sect,"key_ex4",Exkey4);
479 11 set_config_int(cfg_sect,"key_up", DUkey);
480 11 set_config_int(cfg_sect,"key_down", DDkey);
481 11 set_config_int(cfg_sect,"key_left", DLkey);
482 11 set_config_int(cfg_sect,"key_right",DRkey);
483 11 }
484
485 11 set_config_int(cfg_sect,"btn_a",Abtn);
486 11 set_config_int(cfg_sect,"btn_b",Bbtn);
487 11 set_config_int(cfg_sect,"btn_s",Sbtn);
488 11 set_config_int(cfg_sect,"btn_m",Mbtn);
489 11 set_config_int(cfg_sect,"btn_l",Lbtn);
490 11 set_config_int(cfg_sect,"btn_r",Rbtn);
491 11 set_config_int(cfg_sect,"btn_p",Pbtn);
492 11 set_config_int(cfg_sect,"btn_ex1",Exbtn1);
493 11 set_config_int(cfg_sect,"btn_ex2",Exbtn2);
494 11 set_config_int(cfg_sect,"btn_ex3",Exbtn3);
495 11 set_config_int(cfg_sect,"btn_ex4",Exbtn4);
496
497 11 set_config_int(cfg_sect,"btn_up",DUbtn);
498 11 set_config_int(cfg_sect,"btn_down",DDbtn);
499 11 set_config_int(cfg_sect,"btn_left",DLbtn);
500 11 set_config_int(cfg_sect,"btn_right",DRbtn);
501
502 11 set_config_int(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
503
504 11 set_config_int(cfg_sect,"digi",digi_volume);
505 11 set_config_int(cfg_sect,"midi",midi_volume);
506 11 set_config_int(cfg_sect,"sfx",sfx_volume);
507 11 set_config_int(cfg_sect,"emusic",emusic_volume);
508 11 set_config_int(cfg_sect,"pan",pan_style);
509 11 set_config_int(cfg_sect,"zcmusic_bufsz",zcmusic_bufsz);
510 11 set_config_int(cfg_sect,"volkeys",(int32_t)volkeys);
511 11 set_config_int(cfg_sect,"vsync",zc_vsync);
512 11 set_config_int(cfg_sect,"throttlefps", (int32_t)Throttlefps);
513 11 set_config_int(cfg_sect,"translayers",(int32_t)TransLayers);
514 11 set_config_int(cfg_sect,"snapshot_format",SnapshotFormat);
515 11 set_config_int(cfg_sect,"name_entry_mode",NameEntryMode);
516 11 set_config_int(cfg_sect,"showfps",(int32_t)ShowFPS);
517 11 set_config_int(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
518 11 set_config_int(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
519 11 set_config_int(cfg_sect,"drag_aspect",(int32_t)DragAspect);
520 11 set_config_int(cfg_sect,"fastquit",(int32_t)NESquit);
521 11 set_config_int(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
522 11 set_config_int(cfg_sect,"title",title_version);
523 //set_config_int(cfg_sect,"lister_pattern_matching",abc_patternmatch); //Enable once there is a GUI way to toggle this.
524
525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
526 {
527 int o_window_x, o_window_y;
528 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
529 set_config_int(cfg_sect,"window_x",o_window_x);
530 set_config_int(cfg_sect,"window_y",o_window_y);
531 }
532
533
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
534 {
535 double monitor_scale = zc_get_monitor_scale();
536 window_width = al_get_display_width(all_get_display()) / monitor_scale;
537 window_height = al_get_display_height(all_get_display()) / monitor_scale;
538 set_config_int(cfg_sect,"window_width",window_width);
539 set_config_int(cfg_sect,"window_height",window_height);
540 }
541
542 11 set_config_int(cfg_sect,"load_last",loadlast);
543 11 chop_path(qstdir);
544 11 set_config_string(cfg_sect,qst_dir_name,qstdir);
545 11 set_config_string("SAVEFILE","save_filename",save_file_name);
546 11 set_config_int(cfg_sect,"ss_enable",ss_enable);
547 11 set_config_int(cfg_sect,"ss_after",ss_after);
548 11 set_config_int(cfg_sect,"ss_speed",ss_speed);
549 11 set_config_int(cfg_sect,"ss_density",ss_density);
550 11 set_config_int(cfg_sect,"heart_beep",heart_beep);
551 11 set_config_int(cfg_sect,"gui_colorset",gui_colorset);
552 11 set_config_int(cfg_sect,"use_sfx_dat",sfxdat);
553 11 set_config_int(cfg_sect,"fullscreen",fullscreen);
554 11 set_config_int(cfg_sect,"color_depth",zc_color_depth);
555 11 set_config_int(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
556 11 set_config_int(cfg_sect,"force_exit",forceExit);
557
558 #ifdef _WIN32
559 set_config_int(cfg_sect,"debug_console",use_debug_console);
560 set_config_int("CONSOLE","print_ZASM",zasm_debugger);
561 set_config_int("CONSOLE","ZScript_Debugger",zscript_debugger);
562 set_config_int("CONSOLE","console_on_top",console_on_top);
563 //set_config_int(cfg_sect,"use_win7_key_fix",use_win7_keyboard_fix);
564 set_config_int(cfg_sect,"zc_win_proc_fix",use_win32_proc);
565 set_config_int("graphics","disable_direct_updating",disable_direct_updating);
566 set_config_int("zeldadx","use_dwm_flush",use_dwm_flush);
567 set_config_int("zeldadx","midi_patch_fix",midi_patch_fix);
568 set_config_int("CONSOLE","monochrome_debuggers",monochrome_console);
569 set_config_int("zeldadx","debug_console",zconsole);
570 #endif
571
572 #ifdef ALLEGRO_LINUX
573 set_config_string("sound","patches",samplepath); // set to sample sound path set for DIGMIDI driver in Linux ~ Takuya
574 #endif
575
576 11 set_config_int(cfg_sect,"save_indicator",use_save_indicator);
577 11 set_config_int(cfg_sect,"zc_192b163_warp_compatibility",zc_192b163_warp_compatibility);
578
579 11 flush_config_file();
580 #ifdef __EMSCRIPTEN__
581 em_sync_fs();
582 #endif
583 11 }
584
585 //----------------------------------------------------------------
586
587 // Timers
588
589 1049 void fps_callback()
590 {
591 1049 lastfps=framecnt;
592 1049 dword tempsecs = fps_secs;
593 1049 ++tempsecs;
594 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
595 1049 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
596 1049 ++fps_secs;
597 1049 framecnt=0;
598 1049 }
599
600 END_OF_FUNCTION(fps_callback)
601
602 11 int32_t Z_init_timers()
603 {
604 static bool didit = false;
605 const static char *err_str = "Couldn't allocate timer";
606 11 err_str = err_str; //Unused variable warning
607
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(didit)
609 return 1;
610
611 11 didit = true;
612
613 LOCK_VARIABLE(lastfps);
614 LOCK_VARIABLE(framecnt);
615 LOCK_FUNCTION(fps_callback);
616
617
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
618 return 0;
619
620 11 return 1;
621 11 }
622
623 void Z_remove_timers()
624 {
625 remove_int(fps_callback);
626 }
627
628 //----------------------------------------------------------------
629
630 void go()
631 {
632 scare_mouse();
633 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
634 unscare_mouse();
635 }
636
637 void comeback()
638 {
639 scare_mouse();
640 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
641 unscare_mouse();
642 }
643
644 void dump_pal(BITMAP *dest)
645 {
646 for(int32_t i=0; i<256; i++)
647 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
648 }
649
650 //----------------------------------------------------------------
651
652 //Handles converting the mouse sprite from the .dat file
653 11 void load_mouse()
654 {
655 11 system_pal();
656 11 scare_mouse();
657 11 set_mouse_sprite(NULL);
658
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 int32_t sz = vbound(int32_t(16*(is_large ? get_config_float("zeldadx","cursor_scale_large",1.5) : get_config_float("zeldadx","cursor_scale_small",1))),16,80);
659
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t j = 0; j < 4; ++j)
660 {
661 44 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
662 44 BITMAP* subbmp = create_bitmap_ex(8,16,16);
663
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(zcmouse[j])
664 destroy_bitmap(zcmouse[j]);
665 44 zcmouse[j] = create_bitmap_ex(8,sz,sz);
666 44 clear_bitmap(zcmouse[j]);
667 44 clear_bitmap(tmpbmp);
668 44 clear_bitmap(subbmp);
669 44 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
670
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 44 times.
748 for(int32_t x = 0; x < 16; ++x)
671 {
672
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 704 times.
11968 for(int32_t y = 0; y < 16; ++y)
673 {
674 11264 int32_t color = getpixel(tmpbmp, x, y);
675
5/5
✓ Branch 0 taken 10362 times.
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 198 times.
11264 switch(color)
676 {
677 case dvc(1):
678 209 color = jwin_pal[jcCURSORMISC];
679 209 break;
680 case dvc(2):
681 242 color = jwin_pal[jcCURSOROUTLINE];
682 242 break;
683 case dvc(3):
684 253 color = jwin_pal[jcCURSORLIGHT];
685 253 break;
686 case dvc(5):
687 198 color = jwin_pal[jcCURSORDARK];
688 198 break;
689 }
690 11264 putpixel(subbmp, x, y, color);
691 11264 }
692 704 }
693
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(sz!=16)
694 44 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
695 else
696 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
697 44 destroy_bitmap(tmpbmp);
698 44 destroy_bitmap(subbmp);
699 44 }
700 11 set_mouse_sprite(zcmouse[0]);
701
702 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
703 11 set_palette(*hw_palette);
704 11 show_mouse(screen);
705 11 show_mouse(NULL);
706
707 11 unscare_mouse();
708 11 game_pal();
709 11 }
710
711 // sets the video mode and initializes the palette and mouse sprite
712 11 bool game_vid_mode(int32_t mode,int32_t wait)
713 {
714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
715 {
716 return false;
717 }
718
719 11 scrx = (resx-320)>>1;
720 11 scry = (resy-240)>>1;
721
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t q = 0; q < 4; ++q)
722 44 zcmouse[q] = NULL;
723 11 load_mouse();
724 11 set_mouse_sprite(zcmouse[0]);
725
726
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 for(int32_t i=240; i<256; i++)
727 176 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
728
729 11 set_palette(RAMpal);
730 11 clear_to_color(screen,BLACK);
731
732 11 rest(wait);
733 11 return true;
734 11 }
735
736 void null_quest()
737 {
738 char qstdat_string[2048];
739 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
740 strcat(qstdat_string,"#NESQST_NEW_QST");
741
742 #ifdef __EMSCRIPTEN__
743 // The quest template data file is not included because it's really big and isn't really needed
744 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
745 // which is much smaller.
746 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
747 #endif
748
749 byte skip_flags[4] = { 0 };
750
751 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
752 }
753
754 void init_NES_mode()
755 {
756 /*
757 // qst.dat may not load correctly without this...
758 QHeader.templatepath[0]='\0';
759
760 if(!init_colordata(true, &QHeader, &QMisc))
761 {
762 return;
763 }
764
765 loadfullpal();
766 init_tiles(false, &QHeader);
767 */
768 null_quest();
769 }
770
771 //----------------------------------------------------------------
772
773 qword trianglelines[16]=
774 {
775 0x0000000000000000ULL,
776 0xFD00000000000000ULL,
777 0xFDFD000000000000ULL,
778 0xFDFDFD0000000000ULL,
779 0xFDFDFDFD00000000ULL,
780 0xFDFDFDFDFD000000ULL,
781 0xFDFDFDFDFDFD0000ULL,
782 0xFDFDFDFDFDFDFD00ULL,
783 0xFDFDFDFDFDFDFDFDULL,
784 0x00FDFDFDFDFDFDFDULL,
785 0x0000FDFDFDFDFDFDULL,
786 0x000000FDFDFDFDFDULL,
787 0x00000000FDFDFDFDULL,
788 0x0000000000FDFDFDULL,
789 0x000000000000FDFDULL,
790 0x00000000000000FDULL,
791 };
792
793 word screen_triangles[28][32];
794 /*
795 qword triangles[4][16]= //[direction][value]
796 {
797 {
798 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
799 },
800 {
801 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
802 },
803 {
804 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
805 },
806 {
807 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
808 }
809 };
810 */
811
812
813 /*
814 byte triangles[4][16][8]= //[direction][value][line]
815 {
816 {
817 {
818 0, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 1, 0, 0, 0, 0, 0, 0, 0
822 },
823 {
824 2, 1, 0, 0, 0, 0, 0, 0
825 },
826 {
827 3, 2, 1, 0, 0, 0, 0, 0
828 },
829 {
830 4, 3, 2, 1, 0, 0, 0, 0
831 },
832 {
833 5, 4, 3, 2, 1, 0, 0, 0
834 },
835 {
836 6, 5, 4, 3, 2, 1, 0, 0
837 },
838 {
839 7, 6, 5, 4, 3, 2, 1, 0
840 },
841 {
842 8, 7, 6, 5, 4, 3, 2, 1
843 },
844 {
845 8, 8, 7, 6, 5, 4, 3, 2
846 },
847 {
848 8, 8, 8, 7, 6, 5, 4, 3
849 },
850 {
851 8, 8, 8, 8, 7, 6, 5, 4
852 },
853 {
854 8, 8, 8, 8, 8, 7, 6, 5
855 },
856 {
857 8, 8, 8, 8, 8, 8, 7, 6
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 7
861 },
862 {
863 8, 8, 8, 8, 8, 8, 8, 8
864 }
865 },
866 {
867 {
868 0, 0, 0, 0, 0, 0, 0, 0
869 },
870 {
871 15, 0, 0, 0, 0, 0, 0, 0
872 },
873 {
874 14, 15, 0, 0, 0, 0, 0, 0
875 },
876 {
877 13, 14, 15, 0, 0, 0, 0, 0
878 },
879 {
880 12, 13, 14, 15, 0, 0, 0, 0
881 },
882 {
883 11, 12, 13, 14, 15, 0, 0, 0
884 },
885 {
886 10, 11, 12, 13, 14, 15, 0, 0
887 },
888 {
889 9, 10, 11, 12, 13, 14, 15, 0
890 },
891 {
892 8, 9, 10, 11, 12, 13, 14, 15
893 },
894 {
895 8, 8, 9, 10, 11, 12, 13, 14
896 },
897 {
898 8, 8, 8, 9, 10, 11, 12, 13
899 },
900 {
901 8, 8, 8, 8, 9, 10, 11, 12
902 },
903 {
904 8, 8, 8, 8, 8, 9, 10, 11
905 },
906 {
907 8, 8, 8, 8, 8, 8, 9, 10
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 9
911 },
912 {
913 8, 8, 8, 8, 8, 8, 8, 8
914 }
915 },
916 {
917 {
918 0, 0, 0, 0, 0, 0, 0, 0
919 },
920 {
921 0, 0, 0, 0, 0, 0, 0, 1
922 },
923 {
924 0, 0, 0, 0, 0, 0, 1, 2
925 },
926 {
927 0, 0, 0, 0, 0, 1, 2, 3
928 },
929 {
930 0, 0, 0, 0, 1, 2, 3, 4
931 },
932 {
933 0, 0, 0, 1, 2, 3, 4, 5
934 },
935 {
936 0, 0, 1, 2, 3, 4, 5, 6
937 },
938 {
939 0, 1, 2, 3, 4, 5, 6, 7
940 },
941 {
942 1, 2, 3, 4, 5, 6, 7, 8
943 },
944 {
945 2, 3, 4, 5, 6, 7, 8, 8
946 },
947 {
948 3, 4, 5, 6, 7, 8, 8, 8
949 },
950 {
951 4, 5, 6, 7, 8, 8, 8, 8
952 },
953 {
954 5, 6, 7, 8, 8, 8, 8, 8
955 },
956 {
957 6, 7, 8, 8, 8, 8, 8, 8
958 },
959 {
960 7, 8, 8, 8, 8, 8, 8, 8
961 },
962 {
963 8, 8, 8, 8, 8, 8, 8, 8
964 }
965 },
966 {
967 {
968 0, 0, 0, 0, 0, 0, 0, 0
969 },
970 {
971 0, 0, 0, 0, 0, 0, 0, 15
972 },
973 {
974 0, 0, 0, 0, 0, 0, 15, 14
975 },
976 {
977 0, 0, 0, 0, 0, 15, 14, 13
978 },
979 {
980 0, 0, 0, 0, 15, 14, 13, 12
981 },
982 {
983 0, 0, 0, 15, 14, 13, 12, 11
984 },
985 {
986 0, 0, 15, 14, 13, 12, 11, 10
987 },
988 {
989 0, 15, 14, 13, 12, 11, 10, 9
990 },
991 {
992 15, 14, 13, 12, 11, 10, 9, 8
993 },
994 {
995 14, 13, 12, 11, 10, 9, 8, 8
996 },
997 {
998 13, 12, 11, 10, 9, 8, 8, 8
999 },
1000 {
1001 12, 11, 10, 9, 8, 8, 8, 8
1002 },
1003 {
1004 11, 10, 9, 8, 8, 8, 8, 8
1005 },
1006 {
1007 10, 9, 8, 8, 8, 8, 8, 8
1008 },
1009 {
1010 9, 8, 8, 8, 8, 8, 8, 8
1011 },
1012 {
1013 8, 8, 8, 8, 8, 8, 8, 8
1014 }
1015 }
1016 };
1017 */
1018
1019
1020
1021 /*
1022 for (int32_t blockrow=0; blockrow<30; ++i)
1023 {
1024 for (int32_t linerow=0; linerow<8; ++i)
1025 {
1026 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1027 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1028 {
1029 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1030 ++triangleline;
1031 }
1032 }
1033 }
1034 */
1035
1036 // the ULL suffixes are to prevent this warning:
1037 // warning: integer constant is too large for "int32_t" type
1038
1039 qword triangles[4][16][8]= //[direction][value][line]
1040 {
1041 {
1042 {
1043 0x0000000000000000ULL,
1044 0x0000000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL,
1050 0x0000000000000000ULL
1051 },
1052 {
1053 0xFD00000000000000ULL,
1054 0x0000000000000000ULL,
1055 0x0000000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL,
1058 0x0000000000000000ULL,
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL
1061 },
1062 {
1063 0xFDFD000000000000ULL,
1064 0xFD00000000000000ULL,
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL
1071 },
1072 {
1073 0xFDFDFD0000000000ULL,
1074 0xFDFD000000000000ULL,
1075 0xFD00000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL
1081 },
1082 {
1083 0xFDFDFDFD00000000ULL,
1084 0xFDFDFD0000000000ULL,
1085 0xFDFD000000000000ULL,
1086 0xFD00000000000000ULL,
1087 0x0000000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL
1091 },
1092 {
1093 0xFDFDFDFDFD000000ULL,
1094 0xFDFDFDFD00000000ULL,
1095 0xFDFDFD0000000000ULL,
1096 0xFDFD000000000000ULL,
1097 0xFD00000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL
1101 },
1102 {
1103 0xFDFDFDFDFDFD0000ULL,
1104 0xFDFDFDFDFD000000ULL,
1105 0xFDFDFDFD00000000ULL,
1106 0xFDFDFD0000000000ULL,
1107 0xFDFD000000000000ULL,
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL
1111 },
1112 {
1113 0xFDFDFDFDFDFDFD00ULL,
1114 0xFDFDFDFDFDFD0000ULL,
1115 0xFDFDFDFDFD000000ULL,
1116 0xFDFDFDFD00000000ULL,
1117 0xFDFDFD0000000000ULL,
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL
1121 },
1122 {
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFD00ULL,
1125 0xFDFDFDFDFDFD0000ULL,
1126 0xFDFDFDFDFD000000ULL,
1127 0xFDFDFDFD00000000ULL,
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL
1131 },
1132 {
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFD00ULL,
1136 0xFDFDFDFDFDFD0000ULL,
1137 0xFDFDFDFDFD000000ULL,
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL
1141 },
1142 {
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFD00ULL,
1147 0xFDFDFDFDFDFD0000ULL,
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL
1151 },
1152 {
1153 0xFDFDFDFDFDFDFDFDULL,
1154 0xFDFDFDFDFDFDFDFDULL,
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFD00ULL,
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL
1161 },
1162 {
1163 0xFDFDFDFDFDFDFDFDULL,
1164 0xFDFDFDFDFDFDFDFDULL,
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL
1171 },
1172 {
1173 0xFDFDFDFDFDFDFDFDULL,
1174 0xFDFDFDFDFDFDFDFDULL,
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL
1181 },
1182 {
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFDFDULL,
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL
1191 },
1192 {
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL
1201 }
1202 },
1203 {
1204 {
1205 0x0000000000000000ULL,
1206 0x0000000000000000ULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL,
1212 0x0000000000000000ULL
1213 },
1214 {
1215 0x00000000000000FDULL,
1216 0x0000000000000000ULL,
1217 0x0000000000000000ULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL,
1220 0x0000000000000000ULL,
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL
1223 },
1224 {
1225 0x000000000000FDFDULL,
1226 0x00000000000000FDULL,
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL
1233 },
1234 {
1235 0x0000000000FDFDFDULL,
1236 0x000000000000FDFDULL,
1237 0x00000000000000FDULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL
1243 },
1244 {
1245 0x00000000FDFDFDFDULL,
1246 0x0000000000FDFDFDULL,
1247 0x000000000000FDFDULL,
1248 0x00000000000000FDULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL
1253 },
1254 {
1255 0x000000FDFDFDFDFDULL,
1256 0x00000000FDFDFDFDULL,
1257 0x0000000000FDFDFDULL,
1258 0x000000000000FDFDULL,
1259 0x00000000000000FDULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL
1263 },
1264 {
1265 0x0000FDFDFDFDFDFDULL,
1266 0x000000FDFDFDFDFDULL,
1267 0x00000000FDFDFDFDULL,
1268 0x0000000000FDFDFDULL,
1269 0x000000000000FDFDULL,
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL
1273 },
1274 {
1275 0x00FDFDFDFDFDFDFDULL,
1276 0x0000FDFDFDFDFDFDULL,
1277 0x000000FDFDFDFDFDULL,
1278 0x00000000FDFDFDFDULL,
1279 0x0000000000FDFDFDULL,
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL
1283 },
1284 {
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0x00FDFDFDFDFDFDFDULL,
1287 0x0000FDFDFDFDFDFDULL,
1288 0x000000FDFDFDFDFDULL,
1289 0x00000000FDFDFDFDULL,
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL
1293 },
1294 {
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0x00FDFDFDFDFDFDFDULL,
1298 0x0000FDFDFDFDFDFDULL,
1299 0x000000FDFDFDFDFDULL,
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL
1303 },
1304 {
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0x00FDFDFDFDFDFDFDULL,
1309 0x0000FDFDFDFDFDFDULL,
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL
1313 },
1314 {
1315 0xFDFDFDFDFDFDFDFDULL,
1316 0xFDFDFDFDFDFDFDFDULL,
1317 0xFDFDFDFDFDFDFDFDULL,
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0x00FDFDFDFDFDFDFDULL,
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL
1323 },
1324 {
1325 0xFDFDFDFDFDFDFDFDULL,
1326 0xFDFDFDFDFDFDFDFDULL,
1327 0xFDFDFDFDFDFDFDFDULL,
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL
1333 },
1334 {
1335 0xFDFDFDFDFDFDFDFDULL,
1336 0xFDFDFDFDFDFDFDFDULL,
1337 0xFDFDFDFDFDFDFDFDULL,
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL
1343 },
1344 {
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0xFDFDFDFDFDFDFDFDULL,
1347 0xFDFDFDFDFDFDFDFDULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL
1353 },
1354 {
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL
1363 }
1364 },
1365 {
1366 {
1367 0x0000000000000000ULL,
1368 0x0000000000000000ULL,
1369 0x0000000000000000ULL,
1370 0x0000000000000000ULL,
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL
1375 },
1376 {
1377 0x0000000000000000ULL,
1378 0x0000000000000000ULL,
1379 0x0000000000000000ULL,
1380 0x0000000000000000ULL,
1381 0x0000000000000000ULL,
1382 0x0000000000000000ULL,
1383 0x0000000000000000ULL,
1384 0xFD00000000000000ULL
1385 },
1386 {
1387 0x0000000000000000ULL,
1388 0x0000000000000000ULL,
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0xFD00000000000000ULL,
1394 0xFDFD000000000000ULL
1395 },
1396 {
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0xFD00000000000000ULL,
1403 0xFDFD000000000000ULL,
1404 0xFDFDFD0000000000ULL
1405 },
1406 {
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0xFD00000000000000ULL,
1412 0xFDFD000000000000ULL,
1413 0xFDFDFD0000000000ULL,
1414 0xFDFDFDFD00000000ULL
1415 },
1416 {
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0xFD00000000000000ULL,
1421 0xFDFD000000000000ULL,
1422 0xFDFDFD0000000000ULL,
1423 0xFDFDFDFD00000000ULL,
1424 0xFDFDFDFDFD000000ULL
1425 },
1426 {
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0xFD00000000000000ULL,
1430 0xFDFD000000000000ULL,
1431 0xFDFDFD0000000000ULL,
1432 0xFDFDFDFD00000000ULL,
1433 0xFDFDFDFDFD000000ULL,
1434 0xFDFDFDFDFDFD0000ULL
1435 },
1436 {
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL,
1439 0xFDFD000000000000ULL,
1440 0xFDFDFD0000000000ULL,
1441 0xFDFDFDFD00000000ULL,
1442 0xFDFDFDFDFD000000ULL,
1443 0xFDFDFDFDFDFD0000ULL,
1444 0xFDFDFDFDFDFDFD00ULL
1445 },
1446 {
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL,
1449 0xFDFDFD0000000000ULL,
1450 0xFDFDFDFD00000000ULL,
1451 0xFDFDFDFDFD000000ULL,
1452 0xFDFDFDFDFDFD0000ULL,
1453 0xFDFDFDFDFDFDFD00ULL,
1454 0xFDFDFDFDFDFDFDFDULL
1455 },
1456 {
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL,
1459 0xFDFDFDFD00000000ULL,
1460 0xFDFDFDFDFD000000ULL,
1461 0xFDFDFDFDFDFD0000ULL,
1462 0xFDFDFDFDFDFDFD00ULL,
1463 0xFDFDFDFDFDFDFDFDULL,
1464 0xFDFDFDFDFDFDFDFDULL
1465 },
1466 {
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL,
1469 0xFDFDFDFDFD000000ULL,
1470 0xFDFDFDFDFDFD0000ULL,
1471 0xFDFDFDFDFDFDFD00ULL,
1472 0xFDFDFDFDFDFDFDFDULL,
1473 0xFDFDFDFDFDFDFDFDULL,
1474 0xFDFDFDFDFDFDFDFDULL
1475 },
1476 {
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL,
1479 0xFDFDFDFDFDFD0000ULL,
1480 0xFDFDFDFDFDFDFD00ULL,
1481 0xFDFDFDFDFDFDFDFDULL,
1482 0xFDFDFDFDFDFDFDFDULL,
1483 0xFDFDFDFDFDFDFDFDULL,
1484 0xFDFDFDFDFDFDFDFDULL
1485 },
1486 {
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL,
1489 0xFDFDFDFDFDFDFD00ULL,
1490 0xFDFDFDFDFDFDFDFDULL,
1491 0xFDFDFDFDFDFDFDFDULL,
1492 0xFDFDFDFDFDFDFDFDULL,
1493 0xFDFDFDFDFDFDFDFDULL,
1494 0xFDFDFDFDFDFDFDFDULL
1495 },
1496 {
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL,
1502 0xFDFDFDFDFDFDFDFDULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL
1505 },
1506 {
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL
1515 },
1516 {
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL
1525 }
1526 },
1527 {
1528 {
1529 0x0000000000000000ULL,
1530 0x0000000000000000ULL,
1531 0x0000000000000000ULL,
1532 0x0000000000000000ULL,
1533 0x0000000000000000ULL,
1534 0x0000000000000000ULL,
1535 0x0000000000000000ULL,
1536 0x0000000000000000ULL
1537 },
1538 {
1539 0x0000000000000000ULL,
1540 0x0000000000000000ULL,
1541 0x0000000000000000ULL,
1542 0x0000000000000000ULL,
1543 0x0000000000000000ULL,
1544 0x0000000000000000ULL,
1545 0x0000000000000000ULL,
1546 0x00000000000000FDULL
1547 },
1548 {
1549 0x0000000000000000ULL,
1550 0x0000000000000000ULL,
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x00000000000000FDULL,
1556 0x000000000000FDFDULL
1557 },
1558 {
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x00000000000000FDULL,
1565 0x000000000000FDFDULL,
1566 0x0000000000FDFDFDULL
1567 },
1568 {
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x00000000000000FDULL,
1574 0x000000000000FDFDULL,
1575 0x0000000000FDFDFDULL,
1576 0x00000000FDFDFDFDULL
1577 },
1578 {
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x00000000000000FDULL,
1583 0x000000000000FDFDULL,
1584 0x0000000000FDFDFDULL,
1585 0x00000000FDFDFDFDULL,
1586 0x000000FDFDFDFDFDULL
1587 },
1588 {
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x00000000000000FDULL,
1592 0x000000000000FDFDULL,
1593 0x0000000000FDFDFDULL,
1594 0x00000000FDFDFDFDULL,
1595 0x000000FDFDFDFDFDULL,
1596 0x0000FDFDFDFDFDFDULL
1597 },
1598 {
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL,
1601 0x000000000000FDFDULL,
1602 0x0000000000FDFDFDULL,
1603 0x00000000FDFDFDFDULL,
1604 0x000000FDFDFDFDFDULL,
1605 0x0000FDFDFDFDFDFDULL,
1606 0x00FDFDFDFDFDFDFDULL
1607 },
1608 {
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL,
1611 0x0000000000FDFDFDULL,
1612 0x00000000FDFDFDFDULL,
1613 0x000000FDFDFDFDFDULL,
1614 0x0000FDFDFDFDFDFDULL,
1615 0x00FDFDFDFDFDFDFDULL,
1616 0xFDFDFDFDFDFDFDFDULL
1617 },
1618 {
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL,
1621 0x00000000FDFDFDFDULL,
1622 0x000000FDFDFDFDFDULL,
1623 0x0000FDFDFDFDFDFDULL,
1624 0x00FDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL,
1626 0xFDFDFDFDFDFDFDFDULL
1627 },
1628 {
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL,
1631 0x000000FDFDFDFDFDULL,
1632 0x0000FDFDFDFDFDFDULL,
1633 0x00FDFDFDFDFDFDFDULL,
1634 0xFDFDFDFDFDFDFDFDULL,
1635 0xFDFDFDFDFDFDFDFDULL,
1636 0xFDFDFDFDFDFDFDFDULL
1637 },
1638 {
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL,
1641 0x0000FDFDFDFDFDFDULL,
1642 0x00FDFDFDFDFDFDFDULL,
1643 0xFDFDFDFDFDFDFDFDULL,
1644 0xFDFDFDFDFDFDFDFDULL,
1645 0xFDFDFDFDFDFDFDFDULL,
1646 0xFDFDFDFDFDFDFDFDULL
1647 },
1648 {
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL,
1651 0x00FDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL,
1653 0xFDFDFDFDFDFDFDFDULL,
1654 0xFDFDFDFDFDFDFDFDULL,
1655 0xFDFDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL
1657 },
1658 {
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL,
1664 0xFDFDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL
1667 },
1668 {
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL
1677 },
1678 {
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL
1687 }
1688 }
1689 };
1690
1691 int32_t black_opening_count=0;
1692 int32_t black_opening_x,black_opening_y;
1693 int32_t black_opening_shape;
1694
1695 80 int32_t choose_opening_shape()
1696 {
1697 // First, count how many bits are set
1698 80 int32_t numBits=0;
1699 int32_t bitCounter;
1700
1701
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 80 times.
480 for(int32_t i=0; i<bosMAX; i++)
1702 {
1703
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 80 times.
400 if(COOLSCROLL&(1<<i))
1704 80 numBits++;
1705 400 }
1706
1707 // Shouldn't happen...
1708
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(numBits==0)
1709 return bosCIRCLE;
1710
1711 // Pick a bit
1712 80 bitCounter=zc_rand()%numBits+1;
1713
1714
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 for(int32_t i=0; i<bosMAX; i++)
1715 {
1716 // If this bit is set, decrement the bit counter
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(COOLSCROLL&(1<<i))
1718 80 bitCounter--;
1719
1720 // When the counter hits 0, return a value based on
1721 // which bit it stopped on.
1722 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1723
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(bitCounter==0)
1724 80 return i;
1725 }
1726
1727 // Shouldn't be necessary, but the compiler might complain, at least
1728 return bosCIRCLE;
1729 80 }
1730
1731 24 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1732 {
1733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1734
1735 24 int32_t w=256, h=224;
1736 24 int32_t blockrows=28, blockcolumns=32;
1737 24 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1738
1739
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 24 times.
696 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1740 {
1741
2/2
✓ Branch 0 taken 21504 times.
✓ Branch 1 taken 672 times.
22176 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1742 {
1743
2/2
✓ Branch 0 taken 11291 times.
✓ Branch 1 taken 10213 times.
21504 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1744 21504 }
1745 672 }
1746
1747 24 black_opening_count = 66;
1748 24 black_opening_x = x;
1749 24 black_opening_y = y;
1750 24 lensclk = 0;
1751 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1752
1753
1754
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(black_opening_shape == bosFADEBLACK)
1755 {
1756 refreshTints();
1757 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1758 }
1759
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(wait)
1760 {
1761 FFCore.warpScriptCheck();
1762 for(int32_t i=0; i<66; i++)
1763 {
1764 draw_screen(tmpscr);
1765 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1766 syskeys();
1767 advanceframe(true);
1768
1769 if(Quit)
1770 {
1771 break;
1772 }
1773 }
1774 }
1775 24 }
1776
1777 56 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1778 {
1779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1780
1781 56 int32_t w=256, h=224;
1782 56 int32_t blockrows=28, blockcolumns=32;
1783 56 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1784
1785
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 56 times.
1624 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1786 {
1787
2/2
✓ Branch 0 taken 50176 times.
✓ Branch 1 taken 1568 times.
51744 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1788 {
1789
2/2
✓ Branch 0 taken 21441 times.
✓ Branch 1 taken 28735 times.
50176 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1790 50176 }
1791 1568 }
1792
1793 56 black_opening_count = -66;
1794 56 black_opening_x = x;
1795 56 black_opening_y = y;
1796 56 lensclk = 0;
1797
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(black_opening_shape == bosFADEBLACK)
1798 {
1799 refreshTints();
1800 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1801 }
1802
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 38 times.
56 if(wait)
1803 {
1804 38 FFCore.warpScriptCheck();
1805
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2508 times.
2546 for(int32_t i=0; i<66; i++)
1806 {
1807 2508 draw_screen(tmpscr);
1808 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1809 2508 syskeys();
1810 2508 advanceframe(true);
1811
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2508 times.
2508 if(Quit)
1813 {
1814 break;
1815 }
1816 2508 }
1817 38 }
1818 56 }
1819
1820 5280 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1821 {
1822 5280 clear_to_color(tmp_scr,BLACK);
1823 5280 int32_t w=256, h=224;
1824
1825
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5280 times.
5280 switch(black_opening_shape)
1826 {
1827 case bosOVAL:
1828 {
1829 double new_w=(w/2)+abs(w/2-x);
1830 double new_h=(h/2)+abs(h/2-y);
1831 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1832 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1833 break;
1834 }
1835
1836 case bosTRIANGLE:
1837 {
1838 double new_w=(w/2)+abs(w/2-x);
1839 double new_h=(h/2)+abs(h/2-y);
1840 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1841 double P2= (PI/2);
1842 double P23=(2*PI/3);
1843 double P43=(4*PI/3);
1844 double Pa= (-4*PI*a/(3*max_a));
1845 double angle=P2+Pa;
1846 double a0=angle;
1847 double a2=angle+P23;
1848 double a4=angle+P43;
1849 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1850 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1851 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1852 0);
1853 break;
1854 }
1855
1856 case bosSMAS:
1857 {
1858 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1859
1860 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1861 {
1862 for(int32_t linerow=0; linerow<8; ++linerow)
1863 {
1864 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1865
1866 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1867 {
1868 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1869 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1870 [linerow];
1871 ++triangleline;
1872
1873 if(linerow==0)
1874 {
1875 }
1876 }
1877 }
1878 }
1879
1880 break;
1881 }
1882
1883 case bosFADEBLACK:
1884 {
1885 if(black_opening_count<0)
1886 {
1887 black_fade(zc_min(-black_opening_count,63));
1888 }
1889 else if(black_opening_count>0)
1890 {
1891 black_fade(63-zc_max(black_opening_count-3,0));
1892 }
1893 else black_fade(0);
1894 return; //no blitting from tmp_scr!
1895 }
1896
1897 5280 case bosCIRCLE:
1898 default:
1899 {
1900 5280 double new_w=(w/2)+abs(w/2-x);
1901 5280 double new_h=(h/2)+abs(h/2-y);
1902 5280 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1903 //circlefill(tmp_scr,x,y,a<<3,0);
1904 5280 circlefill(tmp_scr,x,y,r,0);
1905 5280 break;
1906 }
1907 }
1908
1909 5280 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1910 5280 }
1911
1912
1913 void black_fade(int32_t fadeamnt)
1914 {
1915 for(int32_t i=0; i < 0xEF; i++)
1916 {
1917 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1918 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1919 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1920 }
1921
1922 refreshpal = true;
1923 }
1924
1925 //----------------------------------------------------------------
1926
1927 240203 bool item_disabled(int32_t item) //is this item disabled?
1928 {
1929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240203 times.
240203 return (item>=0 && game->items_off[item] != 0);
1930 }
1931
1932 733334 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1933 {
1934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 733334 times.
733334 if(current_item(item_type, true) >=item)
1935 {
1936 return true;
1937 }
1938
1939 733334 return false;
1940 733334 }
1941
1942 3609473 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1943 {
1944
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 536130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 315882 times.
✓ Branch 6 taken 2075964 times.
✓ Branch 7 taken 678496 times.
✓ Branch 8 taken 3001 times.
3609473 switch(item_type)
1945 {
1946 case itype_bomb:
1947 case itype_sbomb:
1948 {
1949 int32_t itemid = getItemID(itemsbuf, item_type, it);
1950
1951 if(itemid == -1)
1952 return false;
1953
1954 return (game->get_item(itemid));
1955 }
1956
1957 case itype_clock:
1958 {
1959 536130 int32_t itemid = getItemID(itemsbuf, item_type, it);
1960
1961
2/4
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 536130 times.
✗ Branch 3 not taken.
536130 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1962 return (game->get_item(itemid));
1963 536130 return Hero.getClock()?1:0;
1964 }
1965
1966 case itype_key:
1967 return (game->get_keys()>0);
1968
1969 case itype_magiccontainer:
1970 return (game->get_maxmagic()>=game->get_mp_per_block());
1971
1972 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1973 {
1974
1/3
✓ Branch 0 taken 315882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
315882 switch(it)
1975 {
1976 case -2:
1977 {
1978 for(int32_t i=0; i<MAXLEVELS; i++)
1979 {
1980 if(game->lvlitems[i]&liTRIFORCE)
1981 {
1982 return true;
1983 }
1984 }
1985
1986 return false;
1987 }
1988
1989 case -1:
1990 return (game->lvlitems[dlevel]&liTRIFORCE);
1991
1992 default:
1993
2/4
✓ Branch 0 taken 315882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 315882 times.
315882 if(it>=0&&it<MAXLEVELS)
1994 {
1995 315882 return (game->lvlitems[it]&liTRIFORCE);
1996 }
1997
1998 break;
1999 }
2000
2001 return 0;
2002 }
2003
2004 case itype_map: //it: -2=any, -1=current level, other=that level
2005 {
2006
1/3
✓ Branch 0 taken 2075964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2075964 switch(it)
2007 {
2008 case -2:
2009 {
2010 for(int32_t i=0; i<MAXLEVELS; i++)
2011 {
2012 if(game->lvlitems[i]&liMAP)
2013 {
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021 case -1:
2022 return (game->lvlitems[dlevel]&liMAP)!=0;
2023
2024 default:
2025
2/4
✓ Branch 0 taken 2075964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075964 times.
2075964 if(it>=0&&it<MAXLEVELS)
2026 {
2027 2075964 return (game->lvlitems[it]&liMAP)!=0;
2028 }
2029
2030 break;
2031 }
2032
2033 return 0;
2034 }
2035
2036 case itype_compass: //it: -2=any, -1=current level, other=that level
2037 {
2038
1/3
✓ Branch 0 taken 678496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
678496 switch(it)
2039 {
2040 case -2:
2041 {
2042 for(int32_t i=0; i<MAXLEVELS; i++)
2043 {
2044 if(game->lvlitems[i]&liCOMPASS)
2045 {
2046 return true;
2047 }
2048 }
2049
2050 return false;
2051 }
2052
2053 case -1:
2054 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2055
2056 default:
2057
2/4
✓ Branch 0 taken 678496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 678496 times.
✗ Branch 3 not taken.
678496 if(it>=0&&it<MAXLEVELS)
2058 {
2059 678496 return (game->lvlitems[it]&liCOMPASS)!=0;
2060 }
2061
2062 break;
2063 }
2064 return 0;
2065 }
2066
2067 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2068 {
2069
1/3
✓ Branch 0 taken 3001 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3001 switch(it)
2070 {
2071 case -2:
2072 {
2073 for(int32_t i=0; i<MAXLEVELS; i++)
2074 {
2075 if(game->lvlitems[i]&liBOSSKEY)
2076 {
2077 return true;
2078 }
2079 }
2080
2081 return false;
2082 }
2083
2084 case -1:
2085 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2086
2087 default:
2088
2/4
✓ Branch 0 taken 3001 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3001 times.
3001 if(it>=0&&it<MAXLEVELS)
2089 {
2090 3001 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2091 }
2092 break;
2093 }
2094 return 0;
2095 }
2096
2097 default:
2098 //it=(1<<(it-1));
2099 /*if (item_type>=itype_max)
2100 {
2101 system_pal();
2102 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2103 game_pal();
2104
2105 return false;
2106 }*/
2107 int32_t itemid = getItemID(itemsbuf, item_type, it);
2108
2109 if(itemid == -1)
2110 return false;
2111
2112 return game->get_item(itemid);
2113 }
2114 3609473 }
2115
2116
2117 8982240 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2118 {
2119
9/9
✓ Branch 0 taken 536130 times.
✓ Branch 1 taken 4693200 times.
✓ Branch 2 taken 536130 times.
✓ Branch 3 taken 536130 times.
✓ Branch 4 taken 536130 times.
✓ Branch 5 taken 536130 times.
✓ Branch 6 taken 536130 times.
✓ Branch 7 taken 536130 times.
✓ Branch 8 taken 536130 times.
8982240 switch(item_type)
2120 {
2121 case itype_clock:
2122 {
2123 536130 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2124
2125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 536130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
536130 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2126 return itemsbuf[maxid].fam_type;
2127
2128 536130 return has_item(itype_clock,1) ? 1 : 0;
2129 }
2130
2131 case itype_key:
2132 536130 return game->get_keys();
2133
2134 case itype_lkey:
2135 536130 return game->lvlkeys[get_dlevel()];
2136
2137 case itype_magiccontainer:
2138 536130 return game->get_maxmagic()/game->get_mp_per_block();
2139
2140 case itype_triforcepiece:
2141 {
2142 536130 int32_t count=0;
2143
2144
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2145 {
2146 274498560 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2147 274498560 }
2148
2149 536130 return count;
2150 }
2151
2152 case itype_map:
2153 {
2154 536130 int32_t count=0;
2155
2156
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2157 {
2158 274498560 count+=(game->lvlitems[i]&liMAP)?1:0;
2159 274498560 }
2160
2161 536130 return count;
2162 }
2163
2164 case itype_compass:
2165 {
2166 536130 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 274498560 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2171 274498560 }
2172
2173 536130 return count;
2174 }
2175
2176 case itype_bosskey:
2177 {
2178 536130 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 274498560 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2183 274498560 }
2184
2185 536130 return count;
2186 }
2187
2188 default:
2189 4693200 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2190
2191
2/2
✓ Branch 0 taken 143285 times.
✓ Branch 1 taken 4549915 times.
4693200 if(maxid == -1)
2192 4549915 return 0;
2193
2194 143285 return itemsbuf[maxid].fam_type;
2195 }
2196 8982240 }
2197
2198 8248906 int32_t current_item(int32_t item_type) //item currently being used
2199 {
2200 8248906 return current_item(item_type, true);
2201 }
2202
2203 11 std::map<int32_t, int32_t> itemcache;
2204
2205 // Not actually used by anything at the moment...
2206 void removeFromItemCache(int32_t itemid)
2207 {
2208 itemcache.erase(itemid);
2209 }
2210
2211 1567 void flushItemCache()
2212 {
2213 1567 itemcache.clear();
2214
2215 //also fix the active subscreen if items were deleted -DD
2216
1/2
✓ Branch 0 taken 1567 times.
✗ Branch 1 not taken.
1567 if(game != NULL)
2217 {
2218 1567 verifyBothWeapons();
2219 1567 load_Sitems(&QMisc);
2220 1567 }
2221 1567 }
2222
2223 // This is used often, so it should be as direct as possible.
2224 295663113 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2225 {
2226
2/2
✓ Branch 0 taken 290917829 times.
✓ Branch 1 taken 4745284 times.
295663113 if(jinx_check)
2227 {
2228
4/4
✓ Branch 0 taken 3311719 times.
✓ Branch 1 taken 1433565 times.
✓ Branch 2 taken 3208176 times.
✓ Branch 3 taken 103543 times.
4745284 if(!(HeroSwordClk() || HeroItemClk()))
2229 3208176 jinx_check = false; //not jinxed
2230 4745284 }
2231
4/4
✓ Branch 0 taken 294033588 times.
✓ Branch 1 taken 1629525 times.
✓ Branch 2 taken 1529625 times.
✓ Branch 3 taken 292503963 times.
295663113 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2232 {
2233 292503963 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2234
2235
2/2
✓ Branch 0 taken 291703860 times.
✓ Branch 1 taken 800103 times.
292503963 if(res != itemcache.end())
2236 291703860 return res->second;
2237 800103 }
2238
2239 3959253 int32_t result = -1;
2240 3959253 int32_t highestlevel = -1;
2241
2242
2/2
✓ Branch 0 taken 1013568768 times.
✓ Branch 1 taken 3959253 times.
1017528021 for(int32_t i=0; i<MAXITEMS; i++)
2243 {
2244
5/6
✓ Branch 0 taken 39833833 times.
✓ Branch 1 taken 973734935 times.
✓ Branch 2 taken 226526 times.
✓ Branch 3 taken 39607307 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226526 times.
1013568768 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2245 {
2246
4/4
✓ Branch 0 taken 97564 times.
✓ Branch 1 taken 128962 times.
✓ Branch 2 taken 48243 times.
✓ Branch 3 taken 178283 times.
226526 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2247 {
2248 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2249
2/2
✓ Branch 0 taken 178252 times.
✓ Branch 1 taken 31 times.
178283 if(!checkmagiccost(i))
2250 {
2251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2252 }
2253 178252 }
2254
6/6
✓ Branch 0 taken 131447 times.
✓ Branch 1 taken 95048 times.
✓ Branch 2 taken 17461 times.
✓ Branch 3 taken 77587 times.
✓ Branch 4 taken 73291 times.
✓ Branch 5 taken 21757 times.
226495 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2255 {
2256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21757 times.
21757 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2257 21757 continue;
2258 }
2259
2260
2/2
✓ Branch 0 taken 19193 times.
✓ Branch 1 taken 185545 times.
204738 if(itemsbuf[i].fam_type >= highestlevel)
2261 {
2262 185545 highestlevel = itemsbuf[i].fam_type;
2263 185545 result=i;
2264 185545 }
2265 204738 }
2266 1013546980 }
2267
2268
2/2
✓ Branch 0 taken 1537108 times.
✓ Branch 1 taken 2422145 times.
3959253 if(!jinx_check) //Can't cache jinx_check results
2269 2422145 itemcache[itemtype] = result;
2270 3959253 return result;
2271 295663113 }
2272
2273 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2274 294147881 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2275 {
2276 294147881 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2277
2/2
✓ Branch 0 taken 3230052 times.
✓ Branch 1 taken 290917829 times.
294147881 if(!jinx_check) //If not already a jinx-immune-only check...
2278 {
2279 //And the player IS jinxed...
2280
4/4
✓ Branch 0 taken 289504728 times.
✓ Branch 1 taken 1413101 times.
✓ Branch 2 taken 102131 times.
✓ Branch 3 taken 289402597 times.
290917829 if(HeroSwordClk() || HeroItemClk())
2281 {
2282 //Then do a jinx-immune-only check here
2283 1515232 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2284 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2285 //Should NOT need a compat rule, as this should always return -1 in old quests.
2286
2/2
✓ Branch 0 taken 39576 times.
✓ Branch 1 taken 1475656 times.
1515232 if(ret2 > -1) return ret2;
2287 1475656 }
2288 290878253 }
2289 294108305 return ret;
2290 294147881 }
2291 2098754 int32_t current_item_power(int32_t itemtype)
2292 {
2293 2098754 int32_t result = current_item_id(itemtype,true);
2294
2/2
✓ Branch 0 taken 2053091 times.
✓ Branch 1 taken 45663 times.
2098754 return (result<0) ? 0 : itemsbuf[result].power;
2295 }
2296
2297 int32_t heart_container_id()
2298 {
2299 for(int32_t i=0; i<MAXITEMS; i++)
2300 {
2301 if(itemsbuf[i].family == itype_heartcontainer)
2302 {
2303 return i;
2304 }
2305 }
2306 return -1;
2307 }
2308
2309 536130 int32_t item_tile_mod()
2310 {
2311 536130 int32_t tile=0;
2312
2313
2/2
✓ Branch 0 taken 64903 times.
✓ Branch 1 taken 471227 times.
536130 if(game->get_bombs())
2314 {
2315 471227 int32_t itemid = current_item_id(itype_bomb,false);
2316
3/4
✓ Branch 0 taken 470858 times.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470858 times.
471227 if(itemid > -1 && checkbunny(itemid))
2317 470858 tile+=itemsbuf[itemid].ltm;
2318 471227 }
2319
2320
2/2
✓ Branch 0 taken 525336 times.
✓ Branch 1 taken 10794 times.
536130 if(game->get_sbombs())
2321 {
2322 10794 int32_t itemid = current_item_id(itype_sbomb,false);
2323
3/4
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 6667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4127 times.
10794 if(itemid > -1 && checkbunny(itemid))
2324 4127 tile+=itemsbuf[itemid].ltm;
2325 10794 }
2326
2327
2/2
✓ Branch 0 taken 526672 times.
✓ Branch 1 taken 9458 times.
536130 if(current_item(itype_clock))
2328 {
2329 9458 int32_t itemid =
2330
1/2
✓ Branch 0 taken 9458 times.
✗ Branch 1 not taken.
9458 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2331 ? iClock
2332 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2333
2/4
✓ Branch 0 taken 9458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9458 times.
9458 if(itemid > -1 && checkbunny(itemid))
2334 9458 tile+=itemsbuf[itemid].ltm;
2335 9458 }
2336
2337
2/2
✓ Branch 0 taken 356424 times.
✓ Branch 1 taken 179706 times.
536130 if(current_item(itype_key))
2338 {
2339 179706 int32_t itemid =
2340
1/2
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
179706 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2341 ? iKey
2342 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2343
2/4
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179706 times.
179706 if(itemid > -1 && checkbunny(itemid))
2344 179706 tile+=itemsbuf[itemid].ltm;
2345 179706 }
2346
2347
2/2
✓ Branch 0 taken 485893 times.
✓ Branch 1 taken 50237 times.
536130 if(current_item(itype_lkey))
2348 {
2349 50237 int32_t itemid =
2350
1/2
✓ Branch 0 taken 50237 times.
✗ Branch 1 not taken.
50237 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2351 ? iLevelKey
2352 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2353
2/4
✓ Branch 0 taken 50237 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50237 times.
50237 if(itemid > -1 && checkbunny(itemid))
2354 50237 tile+=itemsbuf[itemid].ltm;
2355 50237 }
2356
2357
2/2
✓ Branch 0 taken 143395 times.
✓ Branch 1 taken 392735 times.
536130 if(current_item(itype_map))
2358 {
2359 392735 int32_t itemid =
2360
1/2
✓ Branch 0 taken 392735 times.
✗ Branch 1 not taken.
392735 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2361 ? iMap
2362 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2363
2/4
✓ Branch 0 taken 392735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392735 times.
392735 if(itemid > -1 && checkbunny(itemid))
2364 392735 tile+=itemsbuf[itemid].ltm;
2365 392735 }
2366
2367
2/2
✓ Branch 0 taken 80101 times.
✓ Branch 1 taken 456029 times.
536130 if(current_item(itype_compass))
2368 {
2369 456029 int32_t itemid =
2370
1/2
✓ Branch 0 taken 456029 times.
✗ Branch 1 not taken.
456029 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2371 ? iCompass
2372 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2373
2/4
✓ Branch 0 taken 456029 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 456029 times.
456029 if(itemid > -1 && checkbunny(itemid))
2374 456029 tile+=itemsbuf[itemid].ltm;
2375 456029 }
2376
2377
2/2
✓ Branch 0 taken 267422 times.
✓ Branch 1 taken 268708 times.
536130 if(current_item(itype_bosskey))
2378 {
2379 268708 int32_t itemid =
2380
1/2
✓ Branch 0 taken 268708 times.
✗ Branch 1 not taken.
268708 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2381 ? iBossKey
2382 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2383
2/4
✓ Branch 0 taken 268708 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 268708 times.
268708 if(itemid > -1 && checkbunny(itemid))
2384 268708 tile+=itemsbuf[itemid].ltm;
2385 268708 }
2386
2387
1/2
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
536130 if(current_item(itype_magiccontainer))
2388 {
2389 int32_t itemid =
2390 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2391 ? iMagicC
2392 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2393 if(itemid > -1 && checkbunny(itemid))
2394 tile+=itemsbuf[itemid].ltm;
2395 }
2396
2397
2/2
✓ Branch 0 taken 90640 times.
✓ Branch 1 taken 445490 times.
536130 if(current_item(itype_triforcepiece))
2398 {
2399 445490 int32_t itemid =
2400
1/2
✓ Branch 0 taken 445490 times.
✗ Branch 1 not taken.
445490 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2401 ? iTriforce
2402 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2403
2/4
✓ Branch 0 taken 445490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 445490 times.
445490 if(itemid > -1 && checkbunny(itemid))
2404 445490 tile+=itemsbuf[itemid].ltm;
2405 445490 }
2406
2407
2/2
✓ Branch 0 taken 536130 times.
✓ Branch 1 taken 274498560 times.
275034690 for(int32_t i=0; i<itype_max; i++)
2408 {
2409
2/2
✓ Branch 0 taken 269011456 times.
✓ Branch 1 taken 5487104 times.
274498560 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2410 {
2411
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2412 {
2413 case itype_bomb:
2414 case itype_sbomb:
2415 case itype_clock:
2416 case itype_key:
2417 case itype_lkey:
2418 case itype_map:
2419 case itype_compass:
2420 case itype_bosskey:
2421 case itype_magiccontainer:
2422 case itype_triforcepiece:
2423 107170 continue; //already handled
2424 }
2425 5379934 }
2426 274391390 int32_t itemid = current_item_id(i,false);
2427
2/2
✓ Branch 0 taken 273855260 times.
✓ Branch 1 taken 536130 times.
274391390 if(i == itype_shield)
2428 536130 itemid = getCurrentShield(false);
2429
2430
3/4
✓ Branch 0 taken 3869137 times.
✓ Branch 1 taken 270522253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3869137 times.
274391390 if(itemid < 0 || !checkbunny(itemid))
2431 270522253 continue;
2432
2433 3869137 itemdata const& itm = itemsbuf[itemid];
2434
2435
2/2
✓ Branch 0 taken 3333007 times.
✓ Branch 1 taken 536130 times.
3869137 switch(itm.family)
2436 {
2437 case itype_shield:
2438
1/2
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
536130 if(itm.flags & ITEM_FLAG9) //active shield
2439 {
2440 if(!usingActiveShield(itemid))
2441 {
2442 tile+=itm.misc6; //'Inactive PTM'
2443 continue;
2444 }
2445 }
2446 536130 break;
2447 }
2448
2449 3869137 tile+=itm.ltm;
2450 3869137 }
2451
2452 536130 return tile;
2453 }
2454
2455 536130 int32_t bunny_tile_mod()
2456 {
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536130 times.
536130 if(Hero.BunnyClock())
2458 {
2459 return game->get_bunny_ltm();
2460 }
2461 536130 return 0;
2462 536130 }
2463
2464 // Hints are drawn on a separate layer to combo reveals.
2465 void draw_lens_under(BITMAP *dest, bool layer)
2466 {
2467 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2468 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2469 //Lens flag 3: Don't show armos/chest/dive items
2470 //Lens flag 4: Show Raft Paths
2471 //Lens flag 5: Show Invisible Enemies
2472 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2473
2474 int32_t strike_hint_table[11]=
2475 {
2476 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2477 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2478 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2479 };
2480
2481 // int32_t page = tmpscr->cpage;
2482 {
2483 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2484 // int32_t temptimer=0;
2485 int32_t tempitem, tempweapon=0;
2486 strike_hint=strike_hint_table[strike_hint_counter];
2487
2488 if(strike_hint_timer>32)
2489 {
2490 strike_hint_timer=0;
2491 strike_hint_counter=((strike_hint_counter+1)%11);
2492 }
2493
2494 ++strike_hint_timer;
2495
2496 for(int32_t i=0; i<176; i++)
2497 {
2498 int32_t x = (i & 15) << 4;
2499 int32_t y = (i & 0xF0) + playing_field_offset;
2500 int32_t tempitemx=-16, tempitemy=-16;
2501 int32_t tempweaponx=-16, tempweapony=-16;
2502
2503 for(int32_t iter=0; iter<2; ++iter)
2504 {
2505 int32_t checkflag=0;
2506
2507 if(iter==0)
2508 {
2509 checkflag=combobuf[tmpscr->data[i]].flag;
2510 }
2511 else
2512 {
2513 checkflag=tmpscr->sflag[i];
2514 }
2515
2516 if(checkflag==mfSTRIKE)
2517 {
2518 if(!hints)
2519 {
2520 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2521 }
2522 else
2523 {
2524 checkflag = strike_hint;
2525 }
2526 }
2527
2528 switch(checkflag)
2529 {
2530 case 0:
2531 case mfZELDA:
2532 case mfPUSHED:
2533 case mfENEMY0:
2534 case mfENEMY1:
2535 case mfENEMY2:
2536 case mfENEMY3:
2537 case mfENEMY4:
2538 case mfENEMY5:
2539 case mfENEMY6:
2540 case mfENEMY7:
2541 case mfENEMY8:
2542 case mfENEMY9:
2543 case mfSINGLE:
2544 case mfSINGLE16:
2545 case mfNOENEMY:
2546 case mfTRAP_H:
2547 case mfTRAP_V:
2548 case mfTRAP_4:
2549 case mfTRAP_LR:
2550 case mfTRAP_UD:
2551 case mfNOGROUNDENEMY:
2552 case mfNOBLOCKS:
2553 case mfSCRIPT1:
2554 case mfSCRIPT2:
2555 case mfSCRIPT3:
2556 case mfSCRIPT4:
2557 case mfSCRIPT5:
2558 case mfSCRIPT6:
2559 case mfSCRIPT7:
2560 case mfSCRIPT8:
2561 case mfSCRIPT9:
2562 case mfSCRIPT10:
2563 case mfSCRIPT11:
2564 case mfSCRIPT12:
2565 case mfSCRIPT13:
2566 case mfSCRIPT14:
2567 case mfSCRIPT15:
2568 case mfSCRIPT16:
2569 case mfSCRIPT17:
2570 case mfSCRIPT18:
2571 case mfSCRIPT19:
2572 case mfSCRIPT20:
2573 case mfPITHOLE:
2574 case mfPITFALLFLOOR:
2575 case mfLAVA:
2576 case mfICE:
2577 case mfICEDAMAGE:
2578 case mfDAMAGE1:
2579 case mfDAMAGE2:
2580 case mfDAMAGE4:
2581 case mfDAMAGE8:
2582 case mfDAMAGE16:
2583 case mfDAMAGE32:
2584 case mfFREEZEALL:
2585 case mfFREZEALLANSFFCS:
2586 case mfFREEZEFFCSOLY:
2587 case mfSCRITPTW1TRIG:
2588 case mfSCRITPTW2TRIG:
2589 case mfSCRITPTW3TRIG:
2590 case mfSCRITPTW4TRIG:
2591 case mfSCRITPTW5TRIG:
2592 case mfSCRITPTW6TRIG:
2593 case mfSCRITPTW7TRIG:
2594 case mfSCRITPTW8TRIG:
2595 case mfSCRITPTW9TRIG:
2596 case mfSCRITPTW10TRIG:
2597 case mfTROWEL:
2598 case mfTROWELNEXT:
2599 case mfTROWELSPECIALITEM:
2600 case mfSLASHPOT:
2601 case mfLIFTPOT:
2602 case mfLIFTORSLASH:
2603 case mfLIFTROCK:
2604 case mfLIFTROCKHEAVY:
2605 case mfDROPITEM:
2606 case mfSPECIALITEM:
2607 case mfDROPKEY:
2608 case mfDROPLKEY:
2609 case mfDROPCOMPASS:
2610 case mfDROPMAP:
2611 case mfDROPBOSSKEY:
2612 case mfSPAWNNPC:
2613 case mfSWITCHHOOK:
2614 case mfSIDEVIEWLADDER:
2615 case mfSIDEVIEWPLATFORM:
2616 case mfNOENEMYSPAWN:
2617 case mfENEMYALL:
2618 case mfNOMIRROR:
2619 case mfUNSAFEGROUND:
2620 case mf168:
2621 case mf169:
2622 case mf170:
2623 case mf171:
2624 case mf172:
2625 case mf173:
2626 case mf174:
2627 case mf175:
2628 case mf176:
2629 case mf177:
2630 case mf178:
2631 case mf179:
2632 case mf180:
2633 case mf181:
2634 case mf182:
2635 case mf183:
2636 case mf184:
2637 case mf185:
2638 case mf186:
2639 case mf187:
2640 case mf188:
2641 case mf189:
2642 case mf190:
2643 case mf191:
2644 case mf192:
2645 case mf193:
2646 case mf194:
2647 case mf195:
2648 case mf196:
2649 case mf197:
2650 case mf198:
2651 case mf199:
2652 case mf200:
2653 case mf201:
2654 case mf202:
2655 case mf203:
2656 case mf204:
2657 case mf205:
2658 case mf206:
2659 case mf207:
2660 case mf208:
2661 case mf209:
2662 case mf210:
2663 case mf211:
2664 case mf212:
2665 case mf213:
2666 case mf214:
2667 case mf215:
2668 case mf216:
2669 case mf217:
2670 case mf218:
2671 case mf219:
2672 case mf220:
2673 case mf221:
2674 case mf222:
2675 case mf223:
2676 case mf224:
2677 case mf225:
2678 case mf226:
2679 case mf227:
2680 case mf228:
2681 case mf229:
2682 case mf230:
2683 case mf231:
2684 case mf232:
2685 case mf233:
2686 case mf234:
2687 case mf235:
2688 case mf236:
2689 case mf237:
2690 case mf238:
2691 case mf239:
2692 case mf240:
2693 case mf241:
2694 case mf242:
2695 case mf243:
2696 case mf244:
2697 case mf245:
2698 case mf246:
2699 case mf247:
2700 case mf248:
2701 case mf249:
2702 case mf250:
2703 case mf251:
2704 case mf252:
2705 case mf253:
2706 case mf254:
2707 case mfEXTENDED:
2708 break;
2709
2710 case mfPUSHUD:
2711 case mfPUSHLR:
2712 case mfPUSH4:
2713 case mfPUSHU:
2714 case mfPUSHD:
2715 case mfPUSHL:
2716 case mfPUSHR:
2717 case mfPUSHUDNS:
2718 case mfPUSHLRNS:
2719 case mfPUSH4NS:
2720 case mfPUSHUNS:
2721 case mfPUSHDNS:
2722 case mfPUSHLNS:
2723 case mfPUSHRNS:
2724 case mfPUSHUDINS:
2725 case mfPUSHLRINS:
2726 case mfPUSH4INS:
2727 case mfPUSHUINS:
2728 case mfPUSHDINS:
2729 case mfPUSHLINS:
2730 case mfPUSHRINS:
2731 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2732 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2733 {
2734 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2735 }
2736
2737 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2738 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2739 {
2740 if(hints)
2741 {
2742 switch(combobuf[tmpscr->data[i]].type)
2743 {
2744 case cPUSH_HEAVY:
2745 case cPUSH_HW:
2746 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2747 tempitemx=x, tempitemy=y;
2748
2749 if(tempitem>-1)
2750 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2751
2752 break;
2753
2754 case cPUSH_HEAVY2:
2755 case cPUSH_HW2:
2756 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2757 tempitemx=x, tempitemy=y;
2758
2759 if(tempitem>-1)
2760 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2761
2762 break;
2763 }
2764 }
2765 }
2766
2767 break;
2768
2769 case mfWHISTLE:
2770 if(hints)
2771 {
2772 tempitem=getItemID(itemsbuf,itype_whistle,1);
2773
2774 if(tempitem<0) break;
2775
2776 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2777 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2778 {
2779 tempitemx=x;
2780 tempitemy=y;
2781 }
2782
2783 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2784 }
2785
2786 break;
2787
2788 //Why is this here?
2789 case mfFAIRY:
2790 case mfMAGICFAIRY:
2791 case mfALLFAIRY:
2792 if(hints)
2793 {
2794 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2795
2796 if(tempitem < 0) break;
2797
2798 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801 tempitemx=x;
2802 tempitemy=y;
2803 }
2804
2805 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2806 }
2807
2808 break;
2809
2810 case mfBCANDLE:
2811 if(!hints)
2812 {
2813 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2814 }
2815 else
2816 {
2817 tempitem=getItemID(itemsbuf,itype_candle,1);
2818
2819 if(tempitem<0) break;
2820
2821 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2822 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2823 {
2824 tempitemx=x;
2825 tempitemy=y;
2826 }
2827
2828 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829 }
2830
2831 break;
2832
2833 case mfRCANDLE:
2834 if(!hints)
2835 {
2836 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2837 }
2838 else
2839 {
2840 tempitem=getItemID(itemsbuf,itype_candle,2);
2841
2842 if(tempitem<0) break;
2843
2844 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2845 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2846 {
2847 tempitemx=x;
2848 tempitemy=y;
2849 }
2850
2851 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2852 }
2853
2854 break;
2855
2856 case mfWANDFIRE:
2857 if(!hints)
2858 {
2859 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2860 }
2861 else
2862 {
2863 tempitem=getItemID(itemsbuf,itype_wand,1);
2864
2865 if(tempitem<0) break;
2866
2867 tempweapon=wFire;
2868
2869 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2870 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2871 {
2872 tempitemx=x;
2873 tempitemy=y;
2874 }
2875 else
2876 {
2877 tempweaponx=x;
2878 tempweapony=y;
2879 }
2880
2881 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2882 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2883 }
2884
2885 break;
2886
2887 case mfDINSFIRE:
2888 if(!hints)
2889 {
2890 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2891 }
2892 else
2893 {
2894 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2895
2896 if(tempitem<0) break;
2897
2898 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2899 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2900 {
2901 tempitemx=x;
2902 tempitemy=y;
2903 }
2904
2905 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2906 }
2907
2908 break;
2909
2910 case mfARROW:
2911 if(!hints)
2912 {
2913 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2914 }
2915 else
2916 {
2917 tempitem=getItemID(itemsbuf,itype_arrow,1);
2918
2919 if(tempitem<0) break;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927
2928 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2929 }
2930
2931 break;
2932
2933 case mfSARROW:
2934 if(!hints)
2935 {
2936 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2937 }
2938 else
2939 {
2940 tempitem=getItemID(itemsbuf,itype_arrow,2);
2941
2942 if(tempitem<0) break;
2943
2944 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2945 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2946 {
2947 tempitemx=x;
2948 tempitemy=y;
2949 }
2950
2951 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2952 }
2953
2954 break;
2955
2956 case mfGARROW:
2957 if(!hints)
2958 {
2959 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2960 }
2961 else
2962 {
2963 tempitem=getItemID(itemsbuf,itype_arrow,3);
2964
2965 if(tempitem<0) break;
2966
2967 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2968 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2969 {
2970 tempitemx=x;
2971 tempitemy=y;
2972 }
2973
2974 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2975 }
2976
2977 break;
2978
2979 case mfBOMB:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2983 }
2984 else
2985 {
2986 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2987 tempweapon = wLitBomb;
2988
2989 //if (tempitem<0) break;
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempweaponx=x;
2994 tempweapony=y;
2995 }
2996
2997 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2998 }
2999
3000 break;
3001
3002 case mfSBOMB:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3006 }
3007 else
3008 {
3009 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3010 //if (tempitem<0) break;
3011 tempweapon = wLitSBomb;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempweaponx=x;
3017 tempweapony=y;
3018 }
3019
3020 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3021 }
3022
3023 break;
3024
3025 case mfARMOS_SECRET:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3029 }
3030 break;
3031
3032 case mfBRANG:
3033 if(!hints)
3034 {
3035 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3036 }
3037 else
3038 {
3039 tempitem=getItemID(itemsbuf,itype_brang,1);
3040
3041 if(tempitem<0) break;
3042
3043 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 tempitemx=x;
3047 tempitemy=y;
3048 }
3049
3050 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3051 }
3052
3053 break;
3054
3055 case mfMBRANG:
3056 if(!hints)
3057 {
3058 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3059 }
3060 else
3061 {
3062 tempitem=getItemID(itemsbuf,itype_brang,2);
3063
3064 if(tempitem<0) break;
3065
3066 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 tempitemx=x;
3070 tempitemy=y;
3071 }
3072
3073 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3074 }
3075
3076 break;
3077
3078 case mfFBRANG:
3079 if(!hints)
3080 {
3081 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3082 }
3083 else
3084 {
3085 tempitem=getItemID(itemsbuf,itype_brang,3);
3086
3087 if(tempitem<0) break;
3088
3089 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 tempitemx=x;
3093 tempitemy=y;
3094 }
3095
3096 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3097 }
3098
3099 break;
3100
3101 case mfWANDMAGIC:
3102 if(!hints)
3103 {
3104 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3105 }
3106 else
3107 {
3108 tempitem=getItemID(itemsbuf,itype_wand,1);
3109
3110 if(tempitem<0) break;
3111
3112 tempweapon=itemsbuf[tempitem].wpn3;
3113
3114 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3115 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3116 {
3117 tempitemx=x;
3118 tempitemy=y;
3119 }
3120 else
3121 {
3122 tempweaponx=x;
3123 tempweapony=y;
3124 --lens_hint_weapon[wMagic][4];
3125
3126 if(lens_hint_weapon[wMagic][4]<-8)
3127 {
3128 lens_hint_weapon[wMagic][4]=8;
3129 }
3130 }
3131
3132 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3133 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3134 }
3135
3136 break;
3137
3138 case mfREFMAGIC:
3139 if(!hints)
3140 {
3141 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3142 }
3143 else
3144 {
3145 tempitem=getItemID(itemsbuf,itype_shield,3);
3146
3147 if(tempitem<0) break;
3148
3149 tempweapon=ewMagic;
3150
3151 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3152 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3153 {
3154 tempitemx=x;
3155 tempitemy=y;
3156 }
3157 else
3158 {
3159 tempweaponx=x;
3160 tempweapony=y;
3161
3162 if(lens_hint_weapon[ewMagic][2]==up)
3163 {
3164 --lens_hint_weapon[ewMagic][4];
3165 }
3166 else
3167 {
3168 ++lens_hint_weapon[ewMagic][4];
3169 }
3170
3171 if(lens_hint_weapon[ewMagic][4]>8)
3172 {
3173 lens_hint_weapon[ewMagic][2]=up;
3174 }
3175
3176 if(lens_hint_weapon[ewMagic][4]<=0)
3177 {
3178 lens_hint_weapon[ewMagic][2]=down;
3179 }
3180 }
3181
3182 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3183 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3184 }
3185
3186 break;
3187
3188 case mfREFFIREBALL:
3189 if(!hints)
3190 {
3191 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3192 }
3193 else
3194 {
3195 tempitem=getItemID(itemsbuf,itype_shield,3);
3196
3197 if(tempitem<0) break;
3198
3199 tempweapon=ewFireball;
3200
3201 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3202 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3203 {
3204 tempitemx=x;
3205 tempitemy=y;
3206 tempweaponx=x;
3207 tempweapony=y;
3208 ++lens_hint_weapon[ewFireball][3];
3209
3210 if(lens_hint_weapon[ewFireball][3]>8)
3211 {
3212 lens_hint_weapon[ewFireball][3]=-8;
3213 lens_hint_weapon[ewFireball][4]=8;
3214 }
3215
3216 if(lens_hint_weapon[ewFireball][3]>0)
3217 {
3218 ++lens_hint_weapon[ewFireball][4];
3219 }
3220 else
3221 {
3222 --lens_hint_weapon[ewFireball][4];
3223 }
3224 }
3225
3226 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3227 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3228 }
3229
3230 break;
3231
3232 case mfSWORD:
3233 if(!hints)
3234 {
3235 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3236 }
3237 else
3238 {
3239 tempitem=getItemID(itemsbuf,itype_sword,1);
3240
3241 if(tempitem<0) break;
3242
3243 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3244 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3245 {
3246 tempitemx=x;
3247 tempitemy=y;
3248 }
3249
3250 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 }
3252
3253 break;
3254
3255 case mfWSWORD:
3256 if(!hints)
3257 {
3258 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3259 }
3260 else
3261 {
3262 tempitem=getItemID(itemsbuf,itype_sword,2);
3263
3264 if(tempitem<0) break;
3265
3266 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 tempitemx=x;
3270 tempitemy=y;
3271 }
3272
3273 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3274 }
3275
3276 break;
3277
3278 case mfMSWORD:
3279 if(!hints)
3280 {
3281 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3282 }
3283 else
3284 {
3285 tempitem=getItemID(itemsbuf,itype_sword,3);
3286
3287 if(tempitem<0) break;
3288
3289 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 tempitemx=x;
3293 tempitemy=y;
3294 }
3295
3296 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3297 }
3298
3299 break;
3300
3301 case mfXSWORD:
3302 if(!hints)
3303 {
3304 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3305 }
3306 else
3307 {
3308 tempitem=getItemID(itemsbuf,itype_sword,4);
3309
3310 if(tempitem<0) break;
3311
3312 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3313 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3314 {
3315 tempitemx=x;
3316 tempitemy=y;
3317 }
3318
3319 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 }
3321
3322 break;
3323
3324 case mfSWORDBEAM:
3325 if(!hints)
3326 {
3327 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3328 }
3329 else
3330 {
3331 tempitem=getItemID(itemsbuf,itype_sword,1);
3332
3333 if(tempitem<0) break;
3334
3335 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3336 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3337 {
3338 tempitemx=x;
3339 tempitemy=y;
3340 }
3341
3342 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3343 }
3344
3345 break;
3346
3347 case mfWSWORDBEAM:
3348 if(!hints)
3349 {
3350 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3351 }
3352 else
3353 {
3354 tempitem=getItemID(itemsbuf,itype_sword,2);
3355
3356 if(tempitem<0) break;
3357
3358 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3359 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3360 {
3361 tempitemx=x;
3362 tempitemy=y;
3363 }
3364
3365 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3366 }
3367
3368 break;
3369
3370 case mfMSWORDBEAM:
3371 if(!hints)
3372 {
3373 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3374 }
3375 else
3376 {
3377 tempitem=getItemID(itemsbuf,itype_sword,3);
3378
3379 if(tempitem<0) break;
3380
3381 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3382 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3383 {
3384 tempitemx=x;
3385 tempitemy=y;
3386 }
3387
3388 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3389 }
3390
3391 break;
3392
3393 case mfXSWORDBEAM:
3394 if(!hints)
3395 {
3396 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3397 }
3398 else
3399 {
3400 tempitem=getItemID(itemsbuf,itype_sword,4);
3401
3402 if(tempitem<0) break;
3403
3404 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3405 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3406 {
3407 tempitemx=x;
3408 tempitemy=y;
3409 }
3410
3411 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3412 }
3413
3414 break;
3415
3416 case mfHOOKSHOT:
3417 if(!hints)
3418 {
3419 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3420 }
3421 else
3422 {
3423 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3424
3425 if(tempitem<0) break;
3426
3427 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3428 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3429 {
3430 tempitemx=x;
3431 tempitemy=y;
3432 }
3433
3434 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3435 }
3436
3437 break;
3438
3439 case mfWAND:
3440 if(!hints)
3441 {
3442 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3443 }
3444 else
3445 {
3446 tempitem=getItemID(itemsbuf,itype_wand,1);
3447
3448 if(tempitem<0) break;
3449
3450 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3451 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3452 {
3453 tempitemx=x;
3454 tempitemy=y;
3455 }
3456
3457 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3458 }
3459
3460 break;
3461
3462 case mfHAMMER:
3463 if(!hints)
3464 {
3465 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3466 }
3467 else
3468 {
3469 tempitem=getItemID(itemsbuf,itype_hammer,1);
3470
3471 if(tempitem<0) break;
3472
3473 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3474 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3475 {
3476 tempitemx=x;
3477 tempitemy=y;
3478 }
3479
3480 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3481 }
3482
3483 break;
3484
3485 case mfARMOS_ITEM:
3486 case mfDIVE_ITEM:
3487 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3488 {
3489 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3490 }
3491 break;
3492
3493 case 16:
3494 case 17:
3495 case 18:
3496 case 19:
3497 case 20:
3498 case 21:
3499 case 22:
3500 case 23:
3501 case 24:
3502 case 25:
3503 case 26:
3504 case 27:
3505 case 28:
3506 case 29:
3507 case 30:
3508 case 31:
3509 if(!hints)
3510 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3511 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3512
3513 break;
3514 case mfSECRETSNEXT:
3515 if(!hints)
3516 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3517 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3518
3519 break;
3520
3521 case mfSTRIKE:
3522 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3523 {
3524 goto special;
3525 }
3526 else
3527 {
3528 break;
3529 }
3530
3531 default: goto special;
3532
3533 special:
3534 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3535 {
3536 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3537 {
3538 rectfill(dest,x,y,x+15,y+15,WHITE);
3539 }
3540 }
3541
3542 break;
3543 }
3544 }
3545 }
3546
3547 if(layer)
3548 {
3549 if(tmpscr->door[0]==dWALK)
3550 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3551
3552 if(tmpscr->door[1]==dWALK)
3553 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3554
3555 if(tmpscr->door[2]==dWALK)
3556 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3557
3558 if(tmpscr->door[3]==dWALK)
3559 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3560
3561 if(tmpscr->door[0]==dBOMB)
3562 {
3563 showbombeddoor(dest, 0);
3564 }
3565
3566 if(tmpscr->door[1]==dBOMB)
3567 {
3568 showbombeddoor(dest, 1);
3569 }
3570
3571 if(tmpscr->door[2]==dBOMB)
3572 {
3573 showbombeddoor(dest, 2);
3574 }
3575
3576 if(tmpscr->door[3]==dBOMB)
3577 {
3578 showbombeddoor(dest, 3);
3579 }
3580 }
3581
3582 if(tmpscr->stairx + tmpscr->stairy)
3583 {
3584 if(!hints)
3585 {
3586 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3587 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3588 }
3589 else
3590 {
3591 if(tmpscr->flags&fWHISTLE)
3592 {
3593 tempitem=getItemID(itemsbuf,itype_whistle,1);
3594 int32_t tempitemx=-16;
3595 int32_t tempitemy=-16;
3596
3597 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3598 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3599 {
3600 tempitemx=tmpscr->stairx;
3601 tempitemy=tmpscr->stairy+playing_field_offset;
3602 }
3603
3604 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3605 }
3606 }
3607 }
3608 }
3609 }
3610
3611 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3612
3613 void draw_lens_over()
3614 {
3615 // Oh, what the heck.
3616 static BITMAP *lens_scr = NULL;
3617 static int32_t last_width = -1;
3618 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3619
3620 // Only redraw the circle if the size has changed
3621 if(width != last_width)
3622 {
3623 if(lens_scr == NULL)
3624 {
3625 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3626 }
3627
3628 clear_to_color(lens_scr, BLACK);
3629 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3630 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3631 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3632 last_width=width;
3633 }
3634
3635 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3636 }
3637
3638 //----------------------------------------------------------------
3639
3640 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3641 {
3642 //recreating a big bitmap every frame is highly sluggish.
3643 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3644 clear_to_color(wavebuf, BLACK);
3645 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3646
3647 int32_t ofs;
3648 // int32_t amplitude=8;
3649 // int32_t wavelength=4;
3650 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3651 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3652 int32_t amp2=168;
3653 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3654 int32_t i=frame%amp2;
3655
3656 for(int32_t j=0; j<168; j++)
3657 {
3658 if(j&1 && interpol)
3659 {
3660 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3661 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3662 }
3663 else
3664 {
3665 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3666 }
3667
3668 if(ofs)
3669 {
3670 for(int32_t k=0; k<256; k++)
3671 {
3672 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3673 }
3674 }
3675 }
3676 }
3677
3678 void draw_fuzzy(int32_t fuzz)
3679 // draws from right half of scrollbuf to framebuf
3680 {
3681 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3682 byte *start, *si, *di;
3683
3684 if(fuzz<1)
3685 fuzz = 1;
3686
3687 xstep = 128%fuzz;
3688
3689 if(xstep > 0)
3690 xstep = fuzz-xstep;
3691
3692 ystep = 112%fuzz;
3693
3694 if(ystep > 0)
3695 ystep = fuzz-ystep;
3696
3697 firsty = 1;
3698
3699 for(y=0; y<224;)
3700 {
3701 start = &(scrollbuf->line[y][256]);
3702
3703 for(dy=0; dy<ystep && dy+y<224; dy++)
3704 {
3705 si = start;
3706 di = &(framebuf->line[y+dy][0]);
3707 i = xstep;
3708 firstx = 1;
3709
3710 for(dx=0; dx<256; dx++)
3711 {
3712 *(di++) = *si;
3713
3714 if(++i >= fuzz)
3715 {
3716 if(!firstx)
3717 si += fuzz;
3718 else
3719 {
3720 si += fuzz-xstep;
3721 firstx = 0;
3722 }
3723
3724 i = 0;
3725 }
3726 }
3727 }
3728
3729 if(!firsty)
3730 y += fuzz;
3731 else
3732 {
3733 y += ystep;
3734 ystep = fuzz;
3735 firsty = 0;
3736 }
3737 }
3738 }
3739
3740 940368 void updatescr(bool allowwavy)
3741 {
3742
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 940357 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
940368 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3743
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 940357 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
940368 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3744
3745
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(toogam)
3746 {
3747 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3748 }
3749
3750
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(Showpal)
3751 dump_pal(framebuf);
3752
3753
2/2
✓ Branch 0 taken 933687 times.
✓ Branch 1 taken 6681 times.
940368 if(!Playing)
3754 6681 black_opening_count=0;
3755
3756
2/2
✓ Branch 0 taken 936672 times.
✓ Branch 1 taken 3696 times.
940368 if(black_opening_count<0) //shape is opening up
3757 {
3758 3696 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3759
3760
2/4
✓ Branch 0 taken 3696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3696 times.
3696 if(Advance||(!Paused))
3761 {
3762 3696 ++black_opening_count;
3763 3696 }
3764 3696 }
3765
2/2
✓ Branch 0 taken 935088 times.
✓ Branch 1 taken 1584 times.
936672 else if(black_opening_count>0) //shape is closing
3766 {
3767 1584 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3768
3769
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
1584 if(Advance||(!Paused))
3770 {
3771 1584 --black_opening_count;
3772 1584 }
3773 1584 }
3774
3775
3/4
✓ Branch 0 taken 935168 times.
✓ Branch 1 taken 5200 times.
✓ Branch 2 taken 935168 times.
✗ Branch 3 not taken.
940368 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3776 {
3777 black_opening_shape = bosCIRCLE;
3778 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3779 refreshTints();
3780 refreshpal=true;
3781 }
3782
3783
2/2
✓ Branch 0 taken 932966 times.
✓ Branch 1 taken 7402 times.
940368 if(refreshpal)
3784 {
3785 7402 refreshpal=false;
3786 7402 RAMpal[253] = _RGB(0,0,0);
3787 7402 RAMpal[254] = _RGB(63,63,63);
3788 7402 hw_palette = &RAMpal;
3789 7402 update_hw_pal = true;
3790
3791 7402 create_rgb_table(&rgb_table, RAMpal, NULL);
3792 7402 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3793 7402 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3794
3795
2/2
✓ Branch 0 taken 1894912 times.
✓ Branch 1 taken 7402 times.
1902314 for(int32_t q=0; q<PAL_SIZE; q++)
3796 {
3797 1894912 trans_table2.data[0][q] = q;
3798 1894912 trans_table2.data[q][q] = q;
3799 1894912 }
3800 7402 }
3801
3802 940368 bool clearwavy = (wavy <= 0);
3803
3804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
940368 if(wavy <= 0)
3805 {
3806 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3807 940368 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3808 940368 }
3809
3810 940368 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3811
3812
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
940368 if(wavy && Playing && allowwavy)
3813 {
3814 draw_wavy(framebuf, wavybuf, wavy,false);
3815 }
3816
3817
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(clearwavy)
3818 940368 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3819 else if(Playing && !Paused)
3820 wavy--; // Wavy was set by a script. Decrement it.
3821
3822
5/6
✓ Branch 0 taken 933687 times.
✓ Branch 1 taken 6681 times.
✓ Branch 2 taken 18595 times.
✓ Branch 3 taken 915092 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18595 times.
940368 if(Playing && msgpos && !screenscrolling)
3823 {
3824
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_bg_display_buf->clip))
3825 18595 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3826
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_portrait_display_buf->clip))
3827 18595 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3828
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_txt_display_buf->clip))
3829 18595 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3830 18595 }
3831
3832 /*
3833 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3834 {
3835 BITMAP* subBmp = 0;
3836 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3837 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3838 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3839 destroy_bitmap(subBmp);
3840 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3841 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3842 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3843 }
3844 */
3845
3846
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3847
3848
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(nosubscr)
3849 {
3850 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3851 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3852 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3853 }
3854
3855 //TODO: Optimize blit 'overcalls' -Gleeok
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
940368 BITMAP *source = nosubscr ? panorama : wavybuf;
3857 940368 blit(source,framebuf,0,0,0,0,256,224);
3858
3859 940368 update_hw_screen();
3860 940368 }
3861
3862 //----------------------------------------------------------------
3863
3864 PALETTE sys_pal;
3865
3866 int32_t onGUISnapshot()
3867 {
3868 char buf[200];
3869 int32_t num=0;
3870 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3871 do
3872 {
3873 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3874 }
3875 while(num<99999 && exists(buf));
3876
3877 BITMAP *b = create_bitmap_ex(8,resx,resy);
3878
3879 if(b)
3880 {
3881 if(MenuOpen)
3882 {
3883 //Cannot load game's palette while GUI elements are in focus. -Z
3884 //If there is a way to do this, then I have missed it.
3885 /*
3886 game_pal();
3887 RAMpal[253] = _RGB(0,0,0);
3888 RAMpal[254] = _RGB(63,63,63);
3889 set_palette_range(RAMpal,0,255,false);
3890 memcpy(RAMpal, snappal, sizeof(snappal));
3891 create_rgb_table(&rgb_table, RAMpal, NULL);
3892 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3893 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3894
3895 for(int32_t q=0; q<PAL_SIZE; q++)
3896 {
3897 trans_table2.data[0][q] = q;
3898 trans_table2.data[q][q] = q;
3899 }
3900 */
3901 //ringcolor(false);
3902 //get_palette(RAMpal);
3903 blit(screen,b,0,0,0,0,resx,resy);
3904 //al_trace("Menu Open\n");
3905 //game_pal();
3906 //PALETTE temppal;
3907 //get_palette(temppal);
3908 //system_pal();
3909 save_bitmap(buf,b,sys_pal);
3910 //save_bitmap(buf,b,RAMpal);
3911 //save_bitmap(buf,b,snappal);
3912 }
3913 else
3914 {
3915 blit(screen,b,0,0,0,0,resx,resy);
3916 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3917 }
3918 destroy_bitmap(b);
3919 }
3920
3921 return D_O_K;
3922 }
3923
3924 int32_t onNonGUISnapshot()
3925 {
3926 PALETTE temppal;
3927 get_palette(temppal);
3928 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3929
3930 char buf[200];
3931 int32_t num=0;
3932
3933 do
3934 {
3935 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3936 }
3937 while(num<99999 && exists(buf));
3938
3939 BITMAP *panorama = create_bitmap_ex(8,256,168);
3940 /*
3941 PALETTE tempRAMpal;
3942 get_palette(tempRAMpal);
3943
3944 if(tmpscr->flags3&fNOSUBSCR)
3945 {
3946 clear_to_color(panorama,0);
3947 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3948 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3949 }
3950 else
3951 {
3952 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3953 }
3954
3955 destroy_bitmap(panorama);
3956 return D_O_K;
3957 */
3958 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3959 {
3960 clear_to_color(panorama,0);
3961 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3962 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3963 }
3964 else
3965 {
3966 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3967 }
3968
3969 destroy_bitmap(panorama);
3970 return D_O_K;
3971 }
3972
3973 int32_t onSnapshot()
3974 {
3975 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3976 {
3977 onGUISnapshot();
3978 }
3979 else
3980 {
3981 onNonGUISnapshot();
3982 }
3983
3984 return D_O_K;
3985 }
3986
3987 int32_t onSaveMapPic()
3988 {
3989 int32_t mapres2 = 0;
3990 char buf[200];
3991 int32_t num=0;
3992 mapscr tmpscr_b[2];
3993 mapscr tmpscr_c[6];
3994 BITMAP* _screen_draw_buffer = NULL;
3995 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3996 set_clip_state(_screen_draw_buffer,1);
3997
3998 for(int32_t i=0; i<6; ++i)
3999 {
4000 tmpscr_c[i] = tmpscr2[i];
4001 tmpscr2[i].zero_memory();
4002
4003 if(i>=2)
4004 {
4005 continue;
4006 }
4007
4008 tmpscr_b[i] = tmpscr[i];
4009 tmpscr[i].zero_memory();
4010 }
4011
4012 do
4013 {
4014 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4015 }
4016 while(num<99999 && exists(buf));
4017
4018 BITMAP* mappic = NULL;
4019
4020
4021 bool done=false, redraw=true;
4022
4023 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4024
4025 if(!mappic)
4026 {
4027 system_pal();
4028 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4029 game_pal();
4030 return D_O_K;;
4031 }
4032
4033 // draw the map
4034 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4035
4036 for(int32_t y=0; y<8; y++)
4037 {
4038 for(int32_t x=0; x<16; x++)
4039 {
4040 if(!displayOnMap(x, y))
4041 {
4042 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4043 }
4044 else
4045 {
4046 int32_t s = (y<<4) + x;
4047 loadscr2(1,s,-1);
4048
4049 for(int32_t i=0; i<6; i++)
4050 {
4051 if(tmpscr[1].layermap[i]<=0)
4052 continue;
4053
4054 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4055 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4056 {
4057 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4058
4059 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4060 }
4061 }
4062
4063 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4069
4070 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4071
4072 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4073 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4074 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4075 {
4076 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4078 }
4079 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4080
4081 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4082
4083 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4084 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4085 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4086 {
4087 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4088 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4089 }
4090 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4091 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4092
4093 }
4094
4095 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4096 }
4097 }
4098
4099 for(int32_t i=0; i<6; ++i)
4100 {
4101 tmpscr2[i]=tmpscr_c[i];
4102
4103 if(i>=2)
4104 {
4105 continue;
4106 }
4107
4108 tmpscr[i]=tmpscr_b[i];
4109 }
4110
4111 save_bitmap(buf,mappic,RAMpal);
4112 destroy_bitmap(mappic);
4113 destroy_bitmap(_screen_draw_buffer);
4114 return D_O_K;
4115 }
4116
4117 /*
4118 int32_t onSaveMapPic()
4119 {
4120 BITMAP* mappic = NULL;
4121 BITMAP* _screen_draw_buffer = NULL;
4122 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4123 int32_t mapres2 = 0;
4124 char buf[20];
4125 int32_t num=0;
4126 set_clip_state(_screen_draw_buffer,1);
4127 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4128
4129 do
4130 {
4131 sprintf(buf, "zelda%03d.png", ++num);
4132 }
4133 while(num<999 && exists(buf));
4134
4135 // if(!mappic) {
4136 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4137
4138 if(!mappic)
4139 {
4140 system_pal();
4141 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4142 game_pal();
4143 return D_O_K;
4144 }
4145
4146 // }
4147
4148 int32_t layermap, layerscreen;
4149 int32_t x2=0;
4150
4151 // draw the map
4152 for(int32_t y=0; y<8; y++)
4153 {
4154 for(int32_t x=0; x<16; x++)
4155 {
4156 int32_t s = (y<<4) + x;
4157
4158 if(!displayOnMap(x, y))
4159 {
4160 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4161 }
4162 else
4163 {
4164 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4165 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4166
4167 for(int32_t k=0; k<4; k++)
4168 {
4169 if(k==2)
4170 {
4171 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4172 }
4173
4174 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4175
4176 if(layermap>-1)
4177 {
4178 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4179
4180 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4181 {
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4185 }
4186 }
4187 else
4188 {
4189 for(int32_t i=0; i<176; i++)
4190 {
4191 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4192 }
4193 }
4194 }
4195 }
4196
4197 for(int32_t i=0; i<176; i++)
4198 {
4199 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4200 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4201 {
4202 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4203 }
4204 }
4205
4206 for(int32_t k=4; k<6; k++)
4207 {
4208 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4209
4210 if(layermap>-1)
4211 {
4212 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4213
4214 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4215 {
4216 for(int32_t i=0; i<176; i++)
4217 {
4218 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4219 }
4220 }
4221 else
4222 {
4223 for(int32_t i=0; i<176; i++)
4224 {
4225 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4226 }
4227 }
4228 }
4229 }
4230 }
4231
4232 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4233 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4234 }
4235
4236 }
4237
4238 save_bitmap(buf,mappic,RAMpal);
4239 destroy_bitmap(mappic);
4240 destroy_bitmap(_screen_draw_buffer);
4241 return D_O_K;
4242 }
4243 */
4244
4245 1 void f_Quit(int32_t type)
4246 {
4247
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4248 return;
4249
4250 1 bool from_menu = is_sys_pal;
4251
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4253 {
4254 1 music_pause();
4255 1 pause_all_sfx();
4256 1 }
4257 1 enter_sys_pal();
4258 1 clear_keybuf();
4259
4260 1 replay_poll();
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4262 1 replay_peek_quit();
4263
4264
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4265 switch(type)
4266 {
4267 case qQUIT:
4268 onQuit();
4269 break;
4270
4271 case qRESET:
4272 onReset();
4273 break;
4274
4275 case qEXIT:
4276 onExit();
4277 break;
4278 }
4279
4280
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4281 {
4282 1 kill_sfx();
4283 1 music_stop();
4284 1 exit_sys_pal();
4285 1 update_hw_screen();
4286 1 }
4287 else
4288 {
4289 exit_sys_pal();
4290 if(!from_menu)
4291 {
4292 music_resume();
4293 resume_all_sfx();
4294 }
4295 }
4296
4297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4298 1 show_mouse(NULL);
4299 1 eat_buttons();
4300
4301 1 zc_readrawkey(KEY_ESC);
4302
4303 1 zc_readrawkey(KEY_ENTER);
4304 1 }
4305
4306 //----------------------------------------------------------------
4307
4308 int32_t onNoWalls()
4309 {
4310 cheats_enqueue(Cheat::Walls);
4311 return D_O_K;
4312 }
4313
4314 int32_t onIgnoreSideview()
4315 {
4316 cheats_enqueue(Cheat::IgnoreSideView);
4317 return D_O_K;
4318 }
4319
4320 955876 int32_t input_idle(bool checkmouse)
4321 {
4322 static int32_t mx, my, mz, mb;
4323
4324
4/6
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✓ Branch 3 taken 807320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 148556 times.
1104432 if(keypressed() || zc_key_pressed() ||
4325
4/8
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148556 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 148556 times.
✗ Branch 7 not taken.
148556 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4326 {
4327 807320 idle_count = 0;
4328
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 807320 times.
807320 if(active_count < MAX_ACTIVE)
4330 {
4331 807320 ++active_count;
4332 807320 }
4333 807320 }
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148556 times.
148556 else if(idle_count < MAX_IDLE)
4335 {
4336 148556 ++idle_count;
4337 148556 active_count = 0;
4338 148556 }
4339
4340 955876 mx = mouse_x;
4341 955876 my = mouse_y;
4342 955876 mz = mouse_z;
4343 955876 mb = mouse_b;
4344
4345 955876 return idle_count;
4346 }
4347
4348 int32_t onGoFast()
4349 {
4350 cheats_enqueue(Cheat::Fast);
4351 return D_O_K;
4352 }
4353
4354 int32_t onKillCheat()
4355 {
4356 cheats_enqueue(Cheat::Kill);
4357 return D_O_K;
4358 }
4359
4360 int32_t onShowLayer0()
4361 {
4362 show_layer_0 = !show_layer_0;
4363 return D_O_K;
4364 }
4365 int32_t onShowLayer1()
4366 {
4367 show_layer_1 = !show_layer_1;
4368 return D_O_K;
4369 }
4370 int32_t onShowLayer2()
4371 {
4372 show_layer_2 = !show_layer_2;
4373 return D_O_K;
4374 }
4375 int32_t onShowLayer3()
4376 {
4377 show_layer_3 = !show_layer_3;
4378 return D_O_K;
4379 }
4380 int32_t onShowLayer4()
4381 {
4382 show_layer_4 = !show_layer_4;
4383 return D_O_K;
4384 }
4385 int32_t onShowLayer5()
4386 {
4387 show_layer_5 = !show_layer_5;
4388 return D_O_K;
4389 }
4390 int32_t onShowLayer6()
4391 {
4392 show_layer_6 = !show_layer_6;
4393 return D_O_K;
4394 }
4395 int32_t onShowLayerO()
4396 {
4397 show_layer_over=!show_layer_over;
4398 return D_O_K;
4399 }
4400 int32_t onShowLayerP()
4401 {
4402 show_layer_push=!show_layer_push;
4403 return D_O_K;
4404 }
4405 int32_t onShowLayerS()
4406 {
4407 show_sprites=!show_sprites;
4408 return D_O_K;
4409 }
4410 int32_t onShowLayerF()
4411 {
4412 show_ffcs=!show_ffcs;
4413 return D_O_K;
4414 }
4415 int32_t onShowLayerW()
4416 {
4417 show_walkflags=!show_walkflags;
4418 return D_O_K;
4419 }
4420 int32_t onShowLayerE()
4421 {
4422 show_effectflags=!show_effectflags;
4423 return D_O_K;
4424 }
4425 int32_t onShowFFScripts()
4426 {
4427 show_ff_scripts=!show_ff_scripts;
4428 return D_O_K;
4429 }
4430 int32_t onShowHitboxes()
4431 {
4432 show_hitboxes=!show_hitboxes;
4433 return D_O_K;
4434 }
4435
4436 int32_t onLightSwitch()
4437 {
4438 cheats_enqueue(Cheat::Light);
4439 return D_O_K;
4440 }
4441
4442 int32_t onGoTo();
4443 int32_t onGoToComplete();
4444
4445 955876 void syskeys()
4446 {
4447 955876 update_system_keys();
4448
4449 int32_t oldtitle_version;
4450
4451
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(close_button_quit)
4452 {
4453 close_button_quit=false;
4454 f_Quit(qEXIT);
4455 }
4456
4457 955876 poll_joystick();
4458
4459
2/10
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 955876 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
955876 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4460 {
4461 oldtitle_version=title_version;
4462 System();
4463 }
4464
4465 955876 mouse_down=gui_mouse_b();
4466
4467
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F1))
4468 {
4469 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4470 {
4471 halt=!halt;
4472 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4473 }
4474 else
4475 {
4476 Throttlefps=!Throttlefps;
4477 logic_counter=0;
4478 }
4479 }
4480
4481 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4482 /*
4483 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4484 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4485 */
4486
4487
1/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4488
4489
1/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4490
4491
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F2)) ShowFPS=!ShowFPS;
4492
4493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4494
4495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_F4) && Playing)
4496 {
4497 Paused=true;
4498 Advance=true;
4499 }
4500
4501
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F6)) onTryQuit();
4502
4503 #ifndef ALLEGRO_MACOSX
4504 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4505
4506 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4507 #else
4508
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4509
4510
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4511 #endif
4512
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
955876 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4513
4514
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if (zc_read_system_key(KEY_F12))
4515 {
4516 onSnapshot();
4517 }
4518
4519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(debug_enabled && zc_read_system_key(KEY_TAB))
4520 set_debug(!get_debug());
4521
4522
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=1)
4523 {
4524
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4525 {
4526 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4527
4528 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4529
4530 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4531
4532 if(zc_readkey(KEY_B))
4533 {
4534 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4535 }
4536
4537 if(zc_readkey(KEY_A))
4538 {
4539 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4540 }
4541 }
4542 13843 }
4543
4544
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=2)
4545 {
4546
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4547 {
4548 if(rI())
4549 {
4550 cheats_enqueue(Cheat::Clock);
4551 }
4552 }
4553 13843 }
4554
4555
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=4)
4556 {
4557
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4558 {
4559 if(rF11())
4560 {
4561 cheats_enqueue(Cheat::Walls);
4562 }
4563
4564 if(rQ())
4565 {
4566 cheats_enqueue(Cheat::Fast);
4567 }
4568
4569 if(zc_readkey(KEY_F))
4570 {
4571 cheats_enqueue(Cheat::Freeze);
4572 }
4573
4574 if(zc_readkey(KEY_G)) onGoToComplete();
4575
4576 if(zc_readkey(KEY_0)) onShowLayer0();
4577
4578 if(zc_readkey(KEY_1)) onShowLayer1();
4579
4580 if(zc_readkey(KEY_2)) onShowLayer2();
4581
4582 if(zc_readkey(KEY_3)) onShowLayer3();
4583
4584 if(zc_readkey(KEY_4)) onShowLayer4();
4585
4586 if(zc_readkey(KEY_5)) onShowLayer5();
4587
4588 if(zc_readkey(KEY_6)) onShowLayer6();
4589
4590 //if(zc_readkey(KEY_7)) onShowLayerO();
4591 if(zc_readkey(KEY_7)) onShowLayerF();
4592
4593 if(zc_readkey(KEY_8)) onShowLayerS();
4594
4595 if(zc_readkey(KEY_W)) onShowLayerW();
4596
4597 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4598
4599 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4600
4601 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4602 if(zc_readkey(KEY_O)) onShowLayerO();
4603 if(zc_readkey(KEY_P)) onShowLayerP();
4604 if(zc_readkey(KEY_C)) onShowHitboxes();
4605 if(zc_readkey(KEY_F)) onShowFFScripts();
4606 }
4607 13843 }
4608
4609
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(volkeys)
4610 {
4611 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4612
4613 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4614
4615 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4616
4617 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4618 }
4619
4620
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
955876 if(!get_debug() || !SystemKeys || replay_is_replaying())
4621 955876 goto bottom;
4622
4623 if(zc_readkey(KEY_D))
4624 {
4625 details = !details;
4626 rectfill(screen,0,0,319,7,BLACK);
4627 rectfill(screen,0,8,31,239,BLACK);
4628 rectfill(screen,288,8,319,239,BLACK);
4629 rectfill(screen,32,232,287,239,BLACK);
4630 }
4631
4632 if(zc_readkey(KEY_P)) Paused=!Paused;
4633
4634 //if(zc_readkey(KEY_P)) centerHero();
4635 if(zc_readkey(KEY_A))
4636 {
4637 Paused=true;
4638 Advance=true;
4639 }
4640
4641 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4642 #ifndef ALLEGRO_MACOSX
4643 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4644
4645 if(zc_readkey(KEY_F7))
4646 {
4647 Matrix(ss_speed, ss_density, 0);
4648 game_pal();
4649 }
4650 #else
4651 // The reason these are different on Mac in the first place is that
4652 // the OS doesn't let us use F9 and F10...
4653 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4654
4655 if(zc_readkey(KEY_F9))
4656 {
4657 Matrix(ss_speed, ss_density, 0);
4658 game_pal();
4659 }
4660 #endif
4661 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4662 {
4663 //change containers
4664 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4665 {
4666 //magic containers
4667 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4668 {
4669 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4670 }
4671 else
4672 {
4673 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4674 }
4675 }
4676 else
4677 {
4678 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4679 {
4680 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4681 }
4682 else
4683 {
4684 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4685 }
4686 }
4687 }
4688
4689 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4690 {
4691 //change containers
4692 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4693 {
4694 //magic containers
4695 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4696 {
4697 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4698 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4699 //heart containers
4700 }
4701 else
4702 {
4703 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4704 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4705 }
4706 }
4707 else
4708 {
4709 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4710 {
4711 game->set_magic(zc_max(game->get_magic()-1,0));
4712 }
4713 else
4714 {
4715 game->set_life(zc_max(game->get_life()-1,0));
4716 }
4717 }
4718 }
4719
4720 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4721
4722 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4723
4724 verifyBothWeapons();
4725
4726 bottom:
4727
4728
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(input_idle(true) > after_time())
4729 {
4730 Matrix(ss_speed, ss_density, 0);
4731 game_pal();
4732 }
4733 //Saffith's method of separating system and game key bindings. Can't do this!!
4734 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4735
4736 //while(Playing && keypressed())
4737 //readkey();
4738 // What's the Playing check for?
4739 955876 clear_keybuf();
4740 955876 }
4741
4742 62414 void checkQuitKeys()
4743 {
4744 #ifndef ALLEGRO_MACOSX
4745 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4746
4747 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4748 #else
4749
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4750
4751
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4752 #endif
4753 62414 }
4754
4755 41529 bool CheatModifierKeys()
4756 {
4757 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4758 // to trigger cheats.
4759
1/2
✓ Branch 0 taken 41529 times.
✗ Branch 1 not taken.
41529 if (replay_is_replaying())
4760 41529 return false;
4761
4762 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4763 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4764 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4765 {
4766 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4767 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4768 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4769 {
4770 return true;
4771 }
4772 }
4773 return false;
4774 41529 }
4775
4776 //99:05:54, for some reason?
4777 #define OLDMAXTIME 21405240
4778 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4779 #define MAXTIME 1944000000
4780
4781 940377 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4782 {
4783
2/2
✓ Branch 0 taken 703445 times.
✓ Branch 1 taken 236932 times.
940377 if(zcmusic!=NULL)
4784 {
4785 236932 zcmusic_poll();
4786 236932 }
4787
4788
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 940377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 940377 times.
940377 while(Paused && !Advance && !Quit)
4789 {
4790 // have to call this, otherwise we'll get an infinite loop
4791 syskeys();
4792 if(allowF6Script)
4793 {
4794 FFCore.runF6Engine();
4795 }
4796 if (replay_get_mode() != ReplayMode::Assert)
4797 updatescr(allowwavy);
4798 throttleFPS();
4799
4800 #ifdef _WIN32
4801
4802 if(use_dwm_flush)
4803 {
4804 do_DwmFlush();
4805 }
4806
4807 #endif
4808
4809 // to keep music playing
4810 if(zcmusic!=NULL)
4811 {
4812 zcmusic_poll();
4813 }
4814 }
4815
4816
2/2
✓ Branch 0 taken 940369 times.
✓ Branch 1 taken 8 times.
940377 if(Quit)
4817 8 return;
4818
4819
3/4
✓ Branch 0 taken 933688 times.
✓ Branch 1 taken 6681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 933688 times.
940369 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4820 933688 game->change_time(1);
4821
4822 940369 Advance=false;
4823
4824
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_active())
4825 {
4826
2/2
✓ Branch 0 taken 655663 times.
✓ Branch 1 taken 284705 times.
940368 if (replay_get_version() >= 3)
4827 284705 replay_poll();
4828
2/2
✓ Branch 0 taken 929615 times.
✓ Branch 1 taken 10753 times.
940368 if (replay_get_version() >= 6)
4829 10753 replay_peek_input();
4830 940368 }
4831 940369 update_keys();
4832
4833 940369 ++frame;
4834
4835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_replaying())
4836 940368 replay_do_cheats();
4837 940369 syskeys();
4838
4839 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4840 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4841 // approach here means it doesn't matter which call adds the cheat.
4842 940369 cheats_execute_queued();
4843
4844
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_replaying())
4845 940368 replay_peek_quit();
4846
2/2
✓ Branch 0 taken 940368 times.
✓ Branch 1 taken 1 times.
940369 if (GameFlags & GAMEFLAG_TRYQUIT)
4847 1 replay_step_quit(0);
4848
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if(allowF6Script)
4849 {
4850 940368 FFCore.runF6Engine();
4851 940368 }
4852
2/2
✓ Branch 0 taken 940336 times.
✓ Branch 1 taken 33 times.
940369 if (Quit)
4853 33 replay_step_quit(Quit);
4854 // Someday... maybe install a Turbo button here?
4855 940369 updatescr(allowwavy);
4856 940369 throttleFPS();
4857
4858 #ifdef _WIN32
4859
4860 if(use_dwm_flush)
4861 {
4862 do_DwmFlush();
4863 }
4864
4865 #endif
4866
4867 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4868
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 940072 times.
940369 if(sfxcleanup)
4869 940072 sfx_cleanup();
4870 940377 }
4871
4872 void zapout()
4873 {
4874 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4875 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4876
4877 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4878 script_drawing_commands.Clear();
4879
4880 // zap out
4881 for(int32_t i=1; i<=24; i++)
4882 {
4883 draw_fuzzy(i);
4884 syskeys();
4885 advanceframe(true);
4886
4887 if(Quit)
4888 {
4889 break;
4890 }
4891 }
4892 }
4893
4894 void zapin()
4895 {
4896 FFCore.warpScriptCheck();
4897 draw_screen(tmpscr);
4898 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4899 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4900 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4901
4902 // zap out
4903 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4904 for(int32_t i=24; i>=1; i--)
4905 {
4906 draw_fuzzy(i);
4907 syskeys();
4908 advanceframe(true);
4909
4910 if(Quit)
4911 {
4912 break;
4913 }
4914 }
4915 }
4916
4917
4918 void wavyout(bool showhero)
4919 {
4920 draw_screen(tmpscr, showhero);
4921 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4922
4923 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4924 clear_to_color(wavebuf,0);
4925 blit(framebuf,wavebuf,0,0,16,0,256,224);
4926
4927 static PALETTE wavepal;
4928
4929 int32_t ofs;
4930 int32_t amplitude=8;
4931
4932 int32_t wavelength=4;
4933 double palpos=0, palstep=4, palstop=126;
4934
4935 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4936 for(int32_t i=0; i<168; i+=wavelength)
4937 {
4938 for(int32_t l=0; l<256; l++)
4939 {
4940 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4941 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4942 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4943 }
4944
4945 palpos+=palstep;
4946
4947 if(palpos>=0)
4948 {
4949 hw_palette = &wavepal;
4950 update_hw_pal = true;
4951 }
4952 else
4953 {
4954 hw_palette = &RAMpal;
4955 update_hw_pal = true;
4956 }
4957
4958 for(int32_t j=0; j+playing_field_offset<224; j++)
4959 {
4960 for(int32_t k=0; k<256; k++)
4961 {
4962 ofs=0;
4963
4964 if((j<i)&&(j&1))
4965 {
4966 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4967 }
4968
4969 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4970 }
4971 }
4972
4973 syskeys();
4974 advanceframe(true);
4975
4976 // animate_combos();
4977 if(Quit)
4978 break;
4979 }
4980
4981 destroy_bitmap(wavebuf);
4982 }
4983
4984 void wavyin()
4985 {
4986 draw_screen(tmpscr);
4987 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4988
4989 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4990 clear_to_color(wavebuf,0);
4991 blit(framebuf,wavebuf,0,0,16,0,256,224);
4992
4993 static PALETTE wavepal;
4994
4995 //Breaks dark rooms.
4996 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4997 /*
4998 loadfullpal();
4999 loadlvlpal(DMaps[currdmap].color);
5000 ringcolor(false);
5001 */
5002 refreshpal=false;
5003 int32_t ofs;
5004 int32_t amplitude=8;
5005 int32_t wavelength=4;
5006 double palpos=168, palstep=4, palstop=126;
5007
5008 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5009 for(int32_t i=0; i<168; i+=wavelength)
5010 {
5011 for(int32_t l=0; l<256; l++)
5012 {
5013 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5014 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5015 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5016 }
5017
5018 palpos-=palstep;
5019
5020 if(palpos>=0)
5021 {
5022 hw_palette = &wavepal;
5023 update_hw_pal = true;
5024 }
5025 else
5026 {
5027 hw_palette = &RAMpal;
5028 update_hw_pal = true;
5029 }
5030
5031 for(int32_t j=0; j+playing_field_offset<224; j++)
5032 {
5033 for(int32_t k=0; k<256; k++)
5034 {
5035 ofs=0;
5036
5037 if((j<(167-i))&&(j&1))
5038 {
5039 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5040 }
5041
5042 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5043 }
5044 }
5045
5046 syskeys();
5047 advanceframe(true);
5048 // animate_combos();
5049
5050 if(Quit)
5051 break;
5052 }
5053
5054 destroy_bitmap(wavebuf);
5055 }
5056
5057 284 void blackscr(int32_t fcnt,bool showsubscr)
5058 {
5059 284 reset_pal_cycling();
5060 284 script_drawing_commands.Clear();
5061
5062 284 FFCore.warpScriptCheck();
5063 284 bool showtime = game->should_show_time();
5064
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 8520 times.
8804 while(fcnt>0)
5065 {
5066 8520 clear_bitmap(framebuf);
5067
5068
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 6180 times.
8520 if(showsubscr)
5069 {
5070 6180 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5071
3/4
✓ Branch 0 taken 6180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 6150 times.
6180 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5072 {
5073 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5074 30 }
5075 6180 }
5076
5077 8520 syskeys();
5078 8520 advanceframe(true);
5079
5080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8520 times.
8520 if(Quit)
5081 break;
5082
5083 8520 --fcnt;
5084 }
5085 284 }
5086
5087 94 void openscreen(int32_t shape)
5088 {
5089 94 reset_pal_cycling();
5090 94 black_opening_count=0;
5091
5092
3/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56 times.
94 if(COOLSCROLL || shape>-1)
5093 {
5094 38 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5095 38 return;
5096 }
5097 else
5098 {
5099 56 Hero.setDontDraw(true);
5100 56 show_subscreen_dmap_dots=false;
5101 56 show_subscreen_numbers=false;
5102 // show_subscreen_items=false;
5103 56 show_subscreen_life=false;
5104 }
5105
5106 56 int32_t x=128;
5107
5108 56 FFCore.warpScriptCheck();
5109
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 4480 times.
4536 for(int32_t i=0; i<80; i++)
5110 {
5111 4480 draw_screen(tmpscr);
5112 //? draw_screen already draws the subscreen -DD
5113 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5114 4480 x=128-(((i*128/80)/8)*8);
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4480 times.
4480 if(x>0)
5117 {
5118 4480 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5119 4480 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5120 4480 }
5121
5122 // x=((80-i)/2)*4;
5123 /*
5124 --x;
5125 switch(++c)
5126 {
5127 case 5: c=0;
5128 case 0:
5129 case 2:
5130 case 3: --x; break;
5131 }
5132 */
5133 4480 syskeys();
5134 4480 advanceframe(true);
5135
5136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4480 times.
4480 if(Quit)
5137 {
5138 break;
5139 }
5140 4480 }
5141
5142 56 Hero.setDontDraw(false);
5143 56 show_subscreen_items=true;
5144 56 show_subscreen_dmap_dots=true;
5145 94 }
5146
5147 void closescreen(int32_t shape)
5148 {
5149 reset_pal_cycling();
5150 black_opening_count=0;
5151
5152 if(COOLSCROLL || shape>-1)
5153 {
5154 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5155 return;
5156 }
5157 else
5158 {
5159 Hero.setDontDraw(true);
5160 show_subscreen_dmap_dots=false;
5161 show_subscreen_numbers=false;
5162 // show_subscreen_items=false;
5163 show_subscreen_life=false;
5164 }
5165
5166 int32_t x=128;
5167
5168 FFCore.warpScriptCheck();
5169 for(int32_t i=79; i>=0; --i)
5170 {
5171 draw_screen(tmpscr);
5172 //? draw_screen already draws the subscreen -DD
5173 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5174 x=128-(((i*128/80)/8)*8);
5175
5176 if(x>0)
5177 {
5178 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5179 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5180 }
5181
5182 // x=((80-i)/2)*4;
5183 /*
5184 --x;
5185 switch(++c)
5186 {
5187 case 5: c=0;
5188 case 0:
5189 case 2:
5190 case 3: --x; break;
5191 }
5192 */
5193 syskeys();
5194 advanceframe(true);
5195
5196 if(Quit)
5197 {
5198 break;
5199 }
5200 }
5201
5202 Hero.setDontDraw(false);
5203 show_subscreen_items=true;
5204 show_subscreen_dmap_dots=true;
5205 }
5206
5207 4 int32_t TriforceCount()
5208 {
5209 4 int32_t c=0;
5210
5211
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i=1; i<=8; i++)
5212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
64 if(game->lvlitems[i]&liTRIFORCE)
5213 32 ++c;
5214
5215 4 return c;
5216 }
5217
5218 int32_t onCustomGame()
5219 {
5220 int32_t file = getsaveslot();
5221
5222 if(file < 0)
5223 return D_O_K;
5224
5225 bool ret = (custom_game(file)!=0);
5226 return ret ? D_CLOSE : D_O_K;
5227 }
5228
5229 int32_t onContinue()
5230 {
5231 return D_CLOSE;
5232 }
5233
5234 int32_t onEsc() // Unused?? -L
5235 {
5236 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5237 }
5238
5239 int32_t onVsync()
5240 {
5241 Throttlefps = !Throttlefps;
5242 save_game_configs();
5243 return D_O_K;
5244 }
5245
5246 int32_t onWinPosSave()
5247 {
5248 SaveWinPos = !SaveWinPos;
5249 return D_O_K;
5250 }
5251
5252 int32_t onClickToFreeze()
5253 {
5254 ClickToFreeze = !ClickToFreeze;
5255 save_game_configs();
5256 return D_O_K;
5257 }
5258
5259 int32_t OnSaveZCConfig()
5260 {
5261 if(jwin_alert3(
5262 "Save Configuration",
5263 "Are you sure that you wish to save your present configuration settings?",
5264 "This will overwrite your prior settings!",
5265 NULL,
5266 "&Yes",
5267 "&No",
5268 NULL,
5269 'y',
5270 'n',
5271 0,
5272 lfont) == 1)
5273 {
5274 save_game_configs();
5275 return D_O_K;
5276 }
5277 else return D_O_K;
5278 }
5279
5280 int32_t OnnClearQuestDir()
5281 {
5282 if(jwin_alert3(
5283 "Clear Current Directory Cache",
5284 "Are you sure that you wish to clear the current cached directory?",
5285 "This will default the current directory to the ROOT for this instance of ZC Player!",
5286 NULL,
5287 "&Yes",
5288 "&No",
5289 NULL,
5290 'y',
5291 'n',
5292 0,
5293 lfont) == 1)
5294 {
5295 set_config_string("zeldadx","win_qst_dir","");
5296 flush_config_file();
5297 strcpy(qstdir,get_config_string("zeldadx","win_qst_dir",""));
5298 //strcpy(filepath,get_config_string("zeldadx","win_qst_dir",""));
5299 save_game_configs();
5300 #ifdef __EMSCRIPTEN__
5301 em_sync_fs();
5302 #endif
5303 return D_O_K;
5304 }
5305 else return D_O_K;
5306 }
5307
5308
5309 int32_t onConsoleZASM()
5310 {
5311 if ( !zasm_debugger )
5312 {
5313 AlertDialog("WARNING: ZASM Debugger",
5314 "Enabling this will open the ZASM Debugger Console"
5315 "\nThis will likely grind ZC to a halt with lag."
5316 "\nTo make any use of this, it is suggested that you read"
5317 "\nthe documentation for 'void Breakpoint(char[] string);'"
5318 " in 'ZScript_Additions.txt'"
5319 "\nThis is not recommended for normal users,"
5320 " and is only intended for ZC developers,"
5321 "\nor quest developers coding directly in ZASM"
5322 "\nAre you sure that you wish to open the ZASM Debugger?",
5323 [&](bool ret,bool)
5324 {
5325 if(ret)
5326 {
5327 FFCore.ZASMPrint(true);
5328 zasm_debugger = 1;
5329 save_game_configs();
5330 }
5331 }).show();
5332 return D_O_K;
5333 }
5334 else
5335 {
5336 zasm_debugger = 0;
5337 save_game_configs();
5338 FFCore.ZASMPrint(false);
5339 return D_O_K;
5340 }
5341 }
5342
5343
5344 int32_t onConsoleZScript()
5345 {
5346 if ( !zscript_debugger )
5347 {
5348 AlertDialog("ZScript Debugger",
5349 "Enabling this will open the ZScript Debugger Console"
5350 "\nThis will display any messages logged by scripts,"
5351 " including script errors."
5352 "\nAre you sure that you wish to open the ZScript Debugger?",
5353 [&](bool ret,bool)
5354 {
5355 if(ret)
5356 {
5357 FFCore.ZScriptConsole(true);
5358 zscript_debugger = 1;
5359 save_game_configs();
5360 }
5361 }).show();
5362 return D_O_K;
5363 }
5364 else
5365 {
5366 zscript_debugger = 0;
5367 save_game_configs();
5368 FFCore.ZScriptConsole(false);
5369 return D_O_K;
5370 }
5371 }
5372
5373
5374 int32_t onFrameSkip()
5375 {
5376 FrameSkip = !FrameSkip;
5377 return D_O_K;
5378 }
5379
5380 int32_t onSaveDragResize()
5381 {
5382 SaveDragResize = !SaveDragResize;
5383 return D_O_K;
5384 }
5385
5386 int32_t onDragAspect()
5387 {
5388 DragAspect = !DragAspect;
5389 return D_O_K;
5390 }
5391
5392 int32_t onTransLayers()
5393 {
5394 TransLayers = !TransLayers;
5395 save_game_configs();
5396 return D_O_K;
5397 }
5398
5399 int32_t onNESquit()
5400 {
5401 NESquit = !NESquit;
5402 save_game_configs();
5403 return D_O_K;
5404 }
5405
5406 int32_t onVolKeys()
5407 {
5408 volkeys = !volkeys;
5409 save_game_configs();
5410 return D_O_K;
5411 }
5412
5413 int32_t onShowFPS()
5414 {
5415 ShowFPS = !ShowFPS;
5416 save_game_configs();
5417 return D_O_K;
5418 }
5419
5420 112793368 bool is_Fkey(int32_t k)
5421 {
5422
2/2
✓ Branch 0 taken 11470512 times.
✓ Branch 1 taken 101322856 times.
112793368 switch(k)
5423 {
5424 case KEY_F1:
5425 case KEY_F2:
5426 case KEY_F3:
5427 case KEY_F4:
5428 case KEY_F5:
5429 case KEY_F6:
5430 case KEY_F7:
5431 case KEY_F8:
5432 case KEY_F9:
5433 case KEY_F10:
5434 case KEY_F11:
5435 case KEY_F12:
5436 11470512 return true;
5437 }
5438
5439 101322856 return false;
5440 112793368 }
5441
5442 void kb_getkey(DIALOG *d)
5443 {
5444 d->flags|=D_SELECTED;
5445
5446 scare_mouse();
5447 jwin_button_proc(MSG_DRAW,d,0);
5448 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5449 // text_mode(vc(11));
5450 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5451 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5452 unscare_mouse();
5453
5454 update_hw_screen(true);
5455
5456 clear_keybuf();
5457 int32_t k = next_press_key();
5458 clear_keybuf();
5459
5460 //shnarf
5461 //47=f1
5462 //59=esc
5463 if(k>0 && k<123 && !((k>46)&&(k<60)))
5464 *((int32_t*)d->dp3) = k;
5465
5466
5467 d->flags&=~D_SELECTED;
5468 }
5469
5470
5471 //Used by all keyboard key settings dialogues.
5472 void kb_clearjoystick(DIALOG *d)
5473 {
5474 d->flags|=D_SELECTED;
5475
5476 scare_mouse();
5477 jwin_button_proc(MSG_DRAW,d,0);
5478 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5479 // text_mode(vc(11));
5480 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5481 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5482 unscare_mouse();
5483
5484 update_hw_screen(true);
5485
5486 clear_keybuf();
5487 int32_t k = next_press_key();
5488 clear_keybuf();
5489
5490 //shnarf
5491 //47=f1
5492 //59=esc
5493 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5494 // *((int32_t*)d->dp3) = k;
5495 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5496
5497
5498 d->flags&=~D_SELECTED;
5499 }
5500
5501 //Clears key to 0.
5502 //Used by all keyboard key settings dialogues.
5503 void kb_clearkey(DIALOG *d)
5504 {
5505 d->flags|=D_SELECTED;
5506
5507 scare_mouse();
5508 jwin_button_proc(MSG_DRAW,d,0);
5509 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5510 // text_mode(vc(11));
5511 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5512 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5513 unscare_mouse();
5514
5515 update_hw_screen(true);
5516
5517 clear_keybuf();
5518 int32_t k = next_press_key();
5519 clear_keybuf();
5520
5521 //shnarf
5522 //47=f1
5523 //59=esc
5524 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5525 // *((int32_t*)d->dp3) = k;
5526 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5527
5528
5529 d->flags&=~D_SELECTED;
5530 }
5531
5532
5533 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5534 {
5535 switch(msg)
5536 {
5537 case MSG_KEY:
5538 case MSG_CLICK:
5539
5540 kb_clearjoystick(d);
5541
5542 while(gui_mouse_b())
5543 {
5544 clear_keybuf();
5545 rest(1);
5546 }
5547
5548 return D_REDRAW;
5549 }
5550
5551 return jwin_button_proc(msg,d,c);
5552 }
5553
5554 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5555 {
5556 switch(msg)
5557 {
5558 case MSG_KEY:
5559 case MSG_CLICK:
5560
5561 kb_getkey(d);
5562
5563 while(gui_mouse_b()) {
5564 clear_keybuf();
5565 rest(1);
5566 }
5567
5568 return D_REDRAW;
5569 }
5570
5571 return jwin_button_proc(msg,d,c);
5572 }
5573
5574 //Only used in keyboard settings dialogues to clear keys.
5575 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5576 {
5577 switch(msg)
5578 {
5579 case MSG_KEY:
5580 case MSG_CLICK:
5581
5582 kb_clearkey(d);
5583
5584 while(gui_mouse_b()) {
5585 clear_keybuf();
5586 rest(1);
5587 }
5588
5589 return D_REDRAW;
5590 }
5591
5592 return jwin_button_proc(msg,d,c);
5593 }
5594
5595 void j_getbtn(DIALOG *d)
5596 {
5597 d->flags|=D_SELECTED;
5598 scare_mouse();
5599 jwin_button_proc(MSG_DRAW,d,0);
5600 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5601 // text_mode(vc(11));
5602 int32_t y = gui_bmp->h/2 - 12;
5603 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5604 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5605 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5606 unscare_mouse();
5607
5608 update_hw_screen(true);
5609
5610 int32_t b = next_press_btn();
5611
5612 if(b>=0)
5613 *((int32_t*)d->dp3) = b;
5614
5615 d->flags&=~D_SELECTED;
5616
5617 if (player)
5618 player->joy_on = TRUE;
5619 }
5620
5621 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5622 {
5623 switch(msg)
5624 {
5625 case MSG_KEY:
5626 case MSG_CLICK:
5627
5628 j_getbtn(d);
5629
5630 while(gui_mouse_b()) {
5631 rest(1);
5632 clear_keybuf();
5633 }
5634
5635 return D_REDRAW;
5636 }
5637
5638 return jwin_button_proc(msg,d,c);
5639 }
5640
5641 //shnarf
5642 const char *key_str[] =
5643 {
5644 "(none) ", "a ", "b ", "c ",
5645 "d ", "e ", "f ", "g ",
5646 "h ", "i ", "j ", "k ",
5647 "l ", "m ", "n ", "o ",
5648 "p ", "q ", "r ", "s ",
5649 "t ", "u ", "v ", "w ",
5650 "x ", "y ", "z ", "0 ",
5651 "1 ", "2 ", "3 ", "4 ",
5652 "5 ", "6 ", "7 ", "8 ",
5653 "9 ", "num 0 ", "num 1 ", "num 2 ",
5654 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5655 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5656 "f2 ", "f3 ", "f4 ", "f5 ",
5657 "f6 ", "f7 ", "f8 ", "f9 ",
5658 "f10 ", "f11 ", "f12 ", "esc ",
5659 "~ ", "- ", "= ", "backspace ",
5660 "tab ", "{ ", "} ", "enter ",
5661 ": ", "quote ", "\\ ", "\\ (2) ",
5662 ", ", ". ", "/ ", "space ",
5663 "insert ", "delete ", "home ", "end ",
5664 "page up ", "page down ", "left ", "right ",
5665 "up ", "down ", "num / ", "num * ",
5666 "num - ", "num + ", "num delete ", "num enter ",
5667 "print screen ", "pause ", "abnt c1 ", "yen ",
5668 "kana ", "convert ", "no convert ", "at ",
5669 "circumflex ", ": (2) ", "kanji ", "num = ",
5670 "back quote ", "; ", "command ", "unknown (0) ",
5671 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5672 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5673 "right shift ", "left control ", "right control", "alt ",
5674 "alt gr ", "left win ", "right win ", "menu ",
5675 "scroll lock ", "number lock ", "caps lock ", "MAX"
5676 };
5677
5678
5679 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5680 //extern int32_t zcmusic_bufsz;
5681
5682 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5683 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5684
5685 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5686 {
5687 //these are here to bypass compiler warnings about unused arguments
5688 c=c;
5689
5690 if(msg==MSG_DRAW)
5691 {
5692 switch(d->w)
5693 {
5694 case 0:
5695 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5696 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5697 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5698 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5699 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5700 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5701 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5702 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5703 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5704 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5705 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5706 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5707 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5708 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5709 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5710 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5711 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5712 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5713 break;
5714
5715 case 1:
5716 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5717 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5718 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5719 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5720 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5721 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5722 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5723 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5724 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5725 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5726 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5727 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5728 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5729 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5730 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5731 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5732 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5733 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5734 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5735 break;
5736
5737 case 2:
5738 sprintf(str_a,"%3d",midi_volume);
5739 sprintf(str_b,"%3d",digi_volume);
5740 sprintf(str_l,"%3d",emusic_volume);
5741 sprintf(str_m,"%3dKB",zcmusic_bufsz);
5742 sprintf(str_r,"%3d",sfx_volume);
5743 strcpy(str_s,pan_str[pan_style]);
5744 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5745 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5746 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5747 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5748 break;
5749 }
5750 }
5751
5752 return D_O_K;
5753 }
5754
5755 int32_t set_vol(void *dp3, int32_t d2)
5756 {
5757 switch(((int32_t*)dp3)[0])
5758 {
5759 case 0:
5760 midi_volume = zc_min(d2<<3,255);
5761 break;
5762
5763 case 1:
5764 digi_volume = zc_min(d2<<3,255);
5765 break;
5766
5767 case 2:
5768 emusic_volume = zc_min(d2<<3,255);
5769 break;
5770
5771 case 3:
5772 sfx_volume = zc_min(d2<<3,255);
5773 break;
5774 }
5775
5776 scare_mouse();
5777 // text_mode(vc(11));
5778 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5779 unscare_mouse();
5780 return D_O_K;
5781 }
5782
5783 int32_t set_pan(void *dp3, int32_t d2)
5784 {
5785 pan_style = vbound(d2,0,3);
5786 scare_mouse();
5787 // text_mode(vc(11));
5788 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5789 unscare_mouse();
5790 return D_O_K;
5791 }
5792
5793 int32_t set_buf(void *dp3, int32_t d2)
5794 {
5795 scare_mouse();
5796 // text_mode(vc(11));
5797 zcmusic_bufsz = d2 + 1;
5798 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5799 unscare_mouse();
5800 return D_O_K;
5801 }
5802
5803 static int32_t gamepad_btn_list[] =
5804 {
5805 6,
5806 7,8,9,10,11,12,13,14,15,16,17,
5807 18,19,20,21,22,23,24,25,26,27,28,
5808 29,30,31,32,33,34,35,36,37,38,39,
5809 -1
5810 };
5811
5812 static int32_t gamepad_dirs_list[] =
5813 {
5814 40,41,42,43,
5815 44,45,46,47,
5816 48,49,50,51,
5817 52,53,54,55,
5818 56,
5819 -1
5820 };
5821
5822 static TABPANEL gamepad_tabs[] =
5823 {
5824 // (text)
5825 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5826 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5827 { NULL, 0, NULL, 0, NULL }
5828 };
5829
5830 static DIALOG gamepad_dlg[] =
5831 {
5832 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5833 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5834 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5835 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5836 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5837 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5838 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5839 // 6
5840 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5841 // 7
5842 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5843 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5844 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5845 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5846 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5847 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5848 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5849 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5850 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5851 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5852 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5853 // 18
5854 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5855 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5856 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5857 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5858 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5859 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5860 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5861 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5862 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5863 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5864 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5865 // 29
5866 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5867 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5868 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5869 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5870 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5871 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5872 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5873 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5874 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5875 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5876 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5877 // 40
5878 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5879 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5880 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5881 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5882 // 44
5883 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5884 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5885 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5886 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5887 // 48
5888 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5889 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5890 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5891 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5892 // 52
5893 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5894 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5895 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5896 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5897 // 56
5898 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5899 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5900 };
5901
5902 static int32_t keyboard_keys_list[] =
5903 {
5904 6,7,8,9,10,
5905 11,12,13,14,15,16,17,18,19,20,
5906 21,22,23,24,25,26,27,28,29,30,
5907 31,32,33,34,35,36,37,38,39,40,
5908 -1
5909 };
5910
5911 static int32_t keyboard_dirs_list[] =
5912 {
5913 41,42,43,44,
5914 45,46,47,48,
5915 49,50,51,52,
5916 53,54,55,56,
5917 -1
5918 };
5919
5920 static int32_t keyboard_mods_list[] =
5921 {
5922 57,58,59,60,
5923 61,62,63,64,
5924 65,66,67,68,
5925 69,70,71,72,
5926 -1
5927 };
5928
5929 static TABPANEL keyboard_control_tabs[] =
5930 {
5931 // (text)
5932 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5933 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5934 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5935 { NULL, 0, NULL, 0, NULL }
5936 };
5937
5938 static DIALOG keyboard_control_dlg[] =
5939 {
5940 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5941 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5942 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5943 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5945 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5946 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 // Keys
5948 // 6
5949 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5950 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5951 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5952 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5953 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5954 // 11
5955 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5956 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5957 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5958 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5959 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5960 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5961 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5962 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5963 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5964 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5965 // 21
5966 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5967 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5968 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5969 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5970 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5971 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5972 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5973 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5974 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5975 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5976 // 31
5977 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5978 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5979 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5980 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5981 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5982 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5983 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5984 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5985 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5986 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5987 // Dirs
5988 // 41
5989 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5990 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5991 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5992 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5993 // 45
5994 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5995 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5996 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5997 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5998 // 49
5999 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
6000 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
6001 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
6002 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
6003 // 53
6004 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
6005 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
6006 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
6007 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
6008 // Mods
6009 // 57
6010 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6011 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6012 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
6013 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
6014 // 61
6015 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
6016 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
6017 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
6018 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
6019 // 65
6020 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
6021 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
6022 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
6023 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
6024 // 69
6025 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
6026 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
6027 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
6028 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
6029 // 73
6030 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6031 };
6032
6033 /*
6034 int32_t midi_dp[3] = {0,147,104};
6035 int32_t digi_dp[3] = {1,147,120};
6036 int32_t pan_dp[3] = {0,147,136};
6037 int32_t buf_dp[3] = {0,147,152};
6038 */
6039 int32_t midi_dp[3] = {0,0,0};
6040 int32_t digi_dp[3] = {1,0,0};
6041 int32_t emus_dp[3] = {2,0,0};
6042 int32_t buf_dp[3] = {0,0,0};
6043 int32_t sfx_dp[3] = {3,0,0};
6044 int32_t pan_dp[3] = {0,0,0};
6045
6046 static DIALOG sound_dlg[] =
6047 {
6048 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6049 11 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6050 11 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6051 11 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6052 11 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6053 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6054 11 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6055 11 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6056 11 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6057 11 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6058 11 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6059 // 10
6060 11 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6061 11 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6062 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6063 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6064 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6065 11 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6066 11 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6067 11 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6068 11 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6069 11 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6070 //20
6071 11 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6072 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6073 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6074 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6075 11 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6076 11 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6077 11 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6078 11 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6079 11 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6080 11 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6081 //30
6082 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6083 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6084 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6085 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6086 };
6087
6088 char zc_builddate[80];
6089 char zc_aboutstr[80];
6090
6091 static DIALOG about_dlg[] =
6092 {
6093 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6094 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6095 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6096 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6097 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6098 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6099 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6100 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6101 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6102 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6103 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6104 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6105 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6106 };
6107
6108
6109 static DIALOG quest_dlg[] =
6110 {
6111 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6112 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6113 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6114 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6115 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6116 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6117 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6118 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6119 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6120 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6121 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6122 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6123 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6124 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6125 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6126 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6127 };
6128
6129 static DIALOG triforce_dlg[] =
6130 {
6131 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6132 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6133 // 1
6134 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6135 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6136 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6137 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6138 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6139 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6140 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6141 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6142 // 9
6143 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6144 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6145 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6146 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6147 };
6148
6149 /*static DIALOG equip_dlg[] =
6150 {
6151 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6152 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6153 // 1
6154 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6155 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6156 // 3
6157 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6158 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6159 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6160 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6161 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6162 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6163 // 9
6164 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6165 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6166 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6167 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6168 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6169 // 14
6170 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6171 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6172 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6173 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6174 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6175 // 19
6176 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6177 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6178 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6179 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6180 // 23
6181 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6182 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6183 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6184 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6185 // 27
6186 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6187 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6188 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6189 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6190 // 31
6191 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6192 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6193 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6194 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6195 // 35
6196 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6197 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6198 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6199 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6200 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6201 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6202 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6203 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6204 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6205 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6206 };
6207
6208 static DIALOG items_dlg[] =
6209 {
6210 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6211 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6212 //1
6213 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6214 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6215 // 3
6216 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6217 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6218 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6219 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6220 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6221 // 8
6222 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6223 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6224 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6225 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6226 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6227 // 13
6228 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6229 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6230 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6231 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6232 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6233 // 18
6234 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6235 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6236 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6237 // 21
6238 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6239 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6240 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6241 // 24
6242 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6243 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6244 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6245 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6246 // 28
6247 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6248 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6249 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6250 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6251 // 32
6252 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6253 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6254 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6255 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6256 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6257 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6258 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6259 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6260 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6261 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6262 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6263 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6264 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6265 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6266 //45
6267 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6268 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6269 };*/
6270
6271
6272
6273 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6274 {
6275 go();
6276 int32_t ret=0;
6277 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6278 comeback();
6279 return ret != 0;
6280 }
6281
6282
6283 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6284 {
6285 if(def!=modulepath)
6286 strcpy(modulepath,def);
6287
6288 if(!usefilename)
6289 {
6290 int32_t i=(int32_t)strlen(modulepath);
6291
6292 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6293 modulepath[i--]=0;
6294 }
6295
6296 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6297 int32_t ret=0;
6298 int32_t sel=0;
6299
6300 if(list==NULL)
6301 {
6302 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6303 }
6304 else
6305 {
6306 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6307 }
6308
6309 return ret!=0;
6310 }
6311
6312 //The Dialogue that loads a ZMOD Module File
6313 int32_t zc_load_zmod_module_file()
6314 {
6315 if ( Playing )
6316 {
6317 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6318 return -1;
6319 }
6320 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6321 return D_CLOSE;
6322
6323 FILE *tempmodule = fopen(modulepath,"r");
6324
6325 if(tempmodule == NULL)
6326 {
6327 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6328 return -1;
6329 }
6330
6331
6332 //Set the module path:
6333 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6334 strcpy(moduledata.module_name, modulepath);
6335 al_trace("New Module Path is: %s \n", moduledata.module_name);
6336 set_config_string("ZCMODULE","current_module",moduledata.module_name);
6337 //save_game_configs();
6338 zcm.init(true); //Load the module values.
6339 moduledata.refresh_title_screen = 1;
6340 // refresh_select_screen = 1;
6341 build_biic_list();
6342 return D_O_K;
6343 }
6344
6345 static DIALOG module_info_dlg[] =
6346 {
6347 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6348
6349
6350 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6351 //1
6352 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6353 //2
6354 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6355 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6356 //4
6357 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6358 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6359 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6360 //7
6361
6362 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6363 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6364 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6365 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6366 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6367 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6368 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6369 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6370 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6371
6372 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6373 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6374 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6375 };
6376
6377 void about_zcplayer_module(const char *prompt,int32_t initialval)
6378 {
6379
6380 module_info_dlg[0].dp2 = lfont;
6381 if ( moduledata.moduletitle[0] != 0 )
6382 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6383
6384 if ( moduledata.moduleauthor[0] != 0 )
6385 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6386
6387 if ( moduledata.moduleinfo0[0] != 0 )
6388 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6389 if ( moduledata.moduleinfo1[0] != 0 )
6390 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6391 if ( moduledata.moduleinfo2[0] != 0 )
6392 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6393 if ( moduledata.moduleinfo3[0] != 0 )
6394 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6395 if ( moduledata.moduleinfo4[0] != 0 )
6396 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6397
6398 char module_date[255];
6399 memset(module_date, 0, sizeof(module_date));
6400 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6401 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6402
6403
6404
6405 char module_vers[255];
6406 memset(module_vers, 0, sizeof(module_vers));
6407 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6408
6409
6410 //sprintf(tilecount,"%d",1);
6411
6412 char module_build[255];
6413 memset(module_build, 0, sizeof(module_build));
6414 if ( moduledata.modbeta )
6415 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6416 else
6417 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6418
6419 module_info_dlg[12].dp = (char*)module_date;
6420 module_info_dlg[13].dp = (char*)module_vers;
6421 module_info_dlg[14].dp = (char*)module_build;
6422
6423 if(is_large)
6424 large_dialog(module_info_dlg);
6425
6426 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6427 jwin_center_dialog(module_info_dlg);
6428
6429
6430 }
6431
6432 int32_t onAbout_ZCP_Module()
6433 {
6434 about_zcplayer_module("About Module (.zmod)", 0);
6435 return D_O_K;
6436 }
6437
6438 //New Modules Menu for 2.55+
6439 static MENU zcmodule_menu[] =
6440 {
6441 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6442 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6443
6444 { NULL, NULL, NULL, 0, NULL }
6445 };
6446
6447 int32_t onToggleRecordingNewSaves()
6448 {
6449 if (zc_get_config("zeldadx", "replay_new_saves", false))
6450 {
6451 zc_set_config("zeldadx", "replay_new_saves", false);
6452 }
6453 else
6454 {
6455 zc_set_config("zeldadx", "replay_new_saves", true);
6456 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6457 NULL,NULL,"OK",NULL,13,27,lfont);
6458 }
6459 return D_O_K;
6460 }
6461
6462 int32_t onStopReplayOrRecord()
6463 {
6464 if (replay_is_replaying())
6465 {
6466 replay_quit();
6467 }
6468 else if (replay_get_mode() == ReplayMode::Record)
6469 {
6470 if (!replay_get_meta_bool("test_mode"))
6471 {
6472 jwin_alert("Recording", "You cannot stop recording a save file.",
6473 NULL,NULL,"OK",NULL,13,27,lfont);
6474 return D_CLOSE;
6475 }
6476
6477 if (jwin_alert("Stop Recording",
6478 "Save replay to disk and stop recording?",
6479 "This will stop the recording.",
6480 NULL,
6481 "Yes","No",13,27,lfont) != 1)
6482 return D_CLOSE;
6483
6484 replay_save();
6485 replay_stop();
6486 }
6487 return D_O_K;
6488 }
6489
6490 static int32_t handle_on_load_replay(ReplayMode mode)
6491 {
6492 if (Playing)
6493 {
6494 if (jwin_alert("Replay - Warning!",
6495 "Loading a replay will exit the current game.",
6496 "All unsaved progress will be lost.",
6497 "Do you wish to continue?",
6498 "Yes","No",13,27,lfont) != 1)
6499 return D_CLOSE;
6500 }
6501
6502 std::string mode_string = replay_mode_to_string(mode);
6503 mode_string[0] = std::toupper(mode_string[0]);
6504
6505 std::string line_1 = "Select a replay file to play back.";
6506 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6507 std::string line_3 = "You can stop the replay and take over manually any time.";
6508 if (mode == ReplayMode::Update)
6509 {
6510 line_1 = "Select a replay file to update.";
6511 line_2 = "WARNING: be sure to back up the zplay file";
6512 line_3 = "and verify that the updated replay works as expected!";
6513 }
6514
6515 if (jwin_alert(mode_string.c_str(),
6516 line_1.c_str(),
6517 line_2.c_str(),
6518 line_3.c_str(),
6519 "OK","Nevermind",13,27,lfont) == 1)
6520 {
6521 char replay_path[2048];
6522 strcpy(replay_path, "replays/");
6523 if (jwin_file_select_ex(
6524 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6525 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6526 return D_CLOSE;
6527
6528 replay_quit();
6529 load_replay_file_deferred(mode, replay_path);
6530 Quit = qRESET;
6531 return D_CLOSE;
6532 }
6533 return D_O_K;
6534 }
6535
6536 int32_t onLoadReplay()
6537 {
6538 return handle_on_load_replay(ReplayMode::Replay);
6539 }
6540
6541 int32_t onLoadReplayAssert()
6542 {
6543 return handle_on_load_replay(ReplayMode::Assert);
6544 }
6545
6546 int32_t onLoadReplayUpdate()
6547 {
6548 return handle_on_load_replay(ReplayMode::Update);
6549 }
6550
6551 int32_t onSaveReplay()
6552 {
6553 if (replay_get_mode() == ReplayMode::Record)
6554 {
6555 if (!replay_get_meta_bool("test_mode"))
6556 {
6557 if (jwin_alert("Save Replay",
6558 "This will save a copy of the replay up to this point.",
6559 "The official replay file will be untouched.",
6560 "Do you wish to continue?",
6561 "Yes","No",13,27,lfont) != 1)
6562 return D_CLOSE;
6563
6564 char replay_path[2048];
6565 strcpy(replay_path, replay_get_filename().c_str());
6566 if (jwin_file_select_ex(
6567 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6568 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6569 return D_CLOSE;
6570
6571 if (fileexists(replay_path))
6572 {
6573 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6574 NULL,NULL,"OK",NULL,13,27,lfont);
6575 return D_CLOSE;
6576 }
6577
6578 replay_save(replay_path);
6579 }
6580 else
6581 {
6582 replay_save();
6583 }
6584 }
6585 return D_O_K;
6586 }
6587
6588 static MENU replay_menu[] =
6589 {
6590 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6591 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6592 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6593 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6594 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6595 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6596
6597 { NULL, NULL, NULL, 0, NULL }
6598 };
6599
6600 static DIALOG credits_dlg[] =
6601 {
6602 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6603 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6604 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6605 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6606 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6607 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6608 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6609 };
6610
6611 11 static ListData dmap_list(dmaplist, &font);
6612
6613 static DIALOG goto_dlg[] =
6614 {
6615 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6616 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6617 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6618 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6619 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6620 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6621 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6622 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6623 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6624 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6625 };
6626
6627 int32_t onGoTo()
6628 {
6629 bool music = false;
6630 music = music;
6631 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6632
6633 goto_dlg[0].dp2=lfont;
6634 goto_dlg[4].d2=cheat_goto_dmap;
6635 goto_dlg[6].dp=cheat_goto_screen_str;
6636
6637 clear_keybuf();
6638
6639 if(is_large)
6640 large_dialog(goto_dlg);
6641
6642 if(zc_popup_dialog(goto_dlg,4)==1)
6643 {
6644 // dmap, screen
6645 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6646 };
6647
6648 return D_O_K;
6649 }
6650
6651 int32_t onGoToComplete()
6652 {
6653 if(!Playing)
6654 {
6655 return D_O_K;
6656 }
6657
6658 system_pal();
6659 music_pause();
6660 pause_all_sfx();
6661 show_mouse(screen);
6662 onGoTo();
6663 eat_buttons();
6664
6665 zc_readrawkey(KEY_ESC);
6666
6667 show_mouse(NULL);
6668 game_pal();
6669 music_resume();
6670 resume_all_sfx();
6671 return D_O_K;
6672 }
6673
6674 int32_t onCredits()
6675 {
6676 go();
6677
6678 BITMAP *win = create_bitmap_ex(8,222,110);
6679
6680 if(!win)
6681 return D_O_K;
6682
6683 int32_t c=0;
6684 int32_t l=0;
6685 int32_t ol=-1;
6686 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6687 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6688 PALETTE tmppal;
6689
6690 rti_gui.transparency_index = 1;
6691
6692 clear_to_color(win, rti_gui.transparency_index);
6693 draw_rle_sprite(win,rle,0,0);
6694 credits_dlg[0].dp2=lfont;
6695 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6696 credits_dlg[2].dp = win;
6697
6698 set_palette_range(black_palette,0,127,false);
6699
6700 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6701
6702 BITMAP* old_screen = screen;
6703 BITMAP* gui_bmp = zc_get_gui_bmp();
6704 ASSERT(gui_bmp);
6705 clear_to_color(gui_bmp, rti_gui.transparency_index);
6706 screen = gui_bmp;
6707
6708 while(update_dialog(p))
6709 {
6710 throttleFPS();
6711 ++c;
6712 l = zc_max((c>>1)-30,0);
6713
6714 if(l > rle->h)
6715 l = c = 0;
6716
6717 if(l > rle->h - 112)
6718 l = rle->h - 112;
6719
6720 clear_bitmap(win);
6721 draw_rle_sprite(win,rle,0,0-l);
6722
6723 if(c<=64)
6724 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6725
6726 set_palette_range(tmppal,0,127,false);
6727
6728 if(l!=ol)
6729 {
6730 scare_mouse();
6731 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6732 unscare_mouse();
6733 SCRFIX();
6734 ol=l;
6735 }
6736
6737 update_hw_screen();
6738 }
6739
6740 screen = old_screen;
6741 system_pal();
6742
6743 shutdown_dialog(p);
6744 destroy_bitmap(win);
6745 //comeback();
6746
6747 rti_gui.transparency_index = 0;
6748
6749 return D_O_K;
6750 }
6751
6752 const char *midilist(int32_t index, int32_t *list_size)
6753 {
6754 if(index<0)
6755 {
6756 *list_size=0;
6757
6758 for(int32_t i=0; i<MAXMIDIS; i++)
6759 if(tunes[i].data)
6760 ++(*list_size);
6761
6762 return NULL;
6763 }
6764
6765 int32_t i=0,m=0;
6766
6767 while(m<=index && i<=MAXMIDIS)
6768 {
6769 if(tunes[i].data)
6770 ++m;
6771
6772 ++i;
6773 }
6774
6775 --i;
6776
6777 if(i==MAXMIDIS && m<index)
6778 return "(null)";
6779
6780 return tunes[i].title;
6781 }
6782
6783 /* ------- MIDI info stuff -------- */
6784
6785 char *text;
6786 midi_info *zmi;
6787 bool dialog_running;
6788 bool listening;
6789
6790 void get_info(int32_t index);
6791
6792 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6793 {
6794 int32_t d2 = d->d2;
6795 int32_t ret = jwin_droplist_proc(msg,d,c);
6796
6797 if(d2!=d->d2)
6798 {
6799 get_info(d->d2);
6800 }
6801
6802 return ret;
6803 }
6804
6805 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6806 {
6807 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6808
6809 int32_t ret = jwin_button_proc(msg,d,c);
6810
6811 if(ret == D_CLOSE)
6812 {
6813 // get current midi index
6814 int32_t index = (d+(d->d1))->d2;
6815 int32_t i=0, m=0;
6816
6817 while(m<=index && i<=MAXMIDIS)
6818 {
6819 if(tunes[i].data)
6820 ++m;
6821
6822 ++i;
6823 }
6824
6825 --i;
6826 jukebox(i);
6827 listening = true;
6828 ret = D_O_K;
6829 }
6830
6831 return ret;
6832 }
6833
6834 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6835 {
6836 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6837
6838 int32_t ret = jwin_button_proc(msg,d,c);
6839
6840 if(ret == D_CLOSE)
6841 {
6842 // get current midi index
6843 int32_t index = (d+(d->d1))->d2;
6844 int32_t i=0, m=0;
6845
6846 while(m<=index && i<=MAXMIDIS)
6847 {
6848 if(tunes[i].data)
6849 ++m;
6850
6851 ++i;
6852 }
6853
6854 --i;
6855
6856 // get file name
6857
6858 int32_t sel=0;
6859 //struct ffblk f;
6860 char title[40] = "Save MIDI: ";
6861 char fname[2048];
6862 memset(fname,0,2048);
6863 static EXT_LIST list[] =
6864 {
6865 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6866 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6867 { NULL, NULL }
6868 };
6869
6870 strcpy(title+11, tunes[i].title);
6871 title[39] = '\0';
6872
6873 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6874 goto done;
6875
6876 if(exists(fname))
6877 {
6878 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6879 goto done;
6880 }
6881
6882 // save midi i
6883
6884 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6885 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6886
6887 done:
6888 chop_path(fname);
6889 ret = D_REDRAW;
6890 }
6891
6892 return ret;
6893 }
6894
6895 11 static ListData midi_list(midilist, &font);
6896
6897 static DIALOG midi_dlg[] =
6898 {
6899 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6900 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6901 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6902 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6903 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6904 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6905 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6906 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6907 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6908 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6909 };
6910
6911 void get_info(int32_t index)
6912 {
6913 int32_t i=0, m=0;
6914
6915 while(m<=index && i<=MAXMIDIS)
6916 {
6917 if(tunes[i].data)
6918 ++m;
6919
6920 ++i;
6921 }
6922
6923 --i;
6924
6925 if(i==MAXMIDIS && m<index)
6926 strcpy(text,"(null)");
6927 else
6928 {
6929 get_midi_info((MIDI*)tunes[i].data,zmi);
6930 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6931 }
6932
6933 midi_dlg[0].dp2=lfont;
6934 midi_dlg[3].dp = text;
6935 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6936 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6937
6938 if(dialog_running)
6939 {
6940 scare_mouse();
6941 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6942 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6943 unscare_mouse();
6944 }
6945 }
6946
6947 int32_t onMIDICredits()
6948 {
6949 text = (char*)malloc(4096);
6950 zmi = (midi_info*)malloc(sizeof(midi_info));
6951
6952 if(!text || !zmi)
6953 {
6954 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6955 return D_O_K;
6956 }
6957
6958 bool do_pause_midi = midi_pos >= 0 && currmidi;
6959 auto restore_midi = currmidi;
6960 if(do_pause_midi)
6961 {
6962 paused_midi_pos = midi_pos;
6963 stop_midi();
6964 midi_paused=true;
6965 midi_suspended = midissuspHALTED;
6966 }
6967
6968 midi_dlg[0].dp2=lfont;
6969 midi_dlg[2].d1 = 0;
6970 midi_dlg[2].d2 = 0;
6971 midi_dlg[4].flags = D_EXIT;
6972 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6973
6974 listening = false;
6975 dialog_running=false;
6976 get_info(0);
6977
6978 dialog_running=true;
6979
6980 if(is_large)
6981 large_dialog(midi_dlg);
6982
6983 zc_popup_dialog(midi_dlg,0);
6984 dialog_running=false;
6985
6986 if(listening)
6987 music_stop();
6988
6989 if(do_pause_midi)
6990 {
6991 midi_suspended = midissuspRESUME;
6992 currmidi = restore_midi;
6993 midi_pos = paused_midi_pos;
6994 }
6995
6996 if(text) free(text);
6997 if(zmi) free(zmi);
6998 return D_O_K;
6999 }
7000
7001 int32_t onAbout()
7002 {
7003 char buf1[80]={0};
7004 std::ostringstream oss;
7005 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
7006 oss << buf1 << '\n';
7007 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
7008 oss << buf1 << '\n';
7009 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
7010 oss << buf1 << '\n';
7011 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
7012 oss << buf1 << '\n';
7013
7014 InfoDialog("About ZC", oss.str()).show();
7015 return D_O_K;
7016 }
7017
7018 int32_t onQuest()
7019 {
7020 char fname[100];
7021 strcpy(fname, get_filename(qstpath));
7022 quest_dlg[0].dp2=lfont;
7023 quest_dlg[1].dp = fname;
7024
7025 if(QHeader.quest_number==0)
7026 sprintf(str_a,"Custom");
7027 else
7028 sprintf(str_a,"%d",QHeader.quest_number);
7029
7030 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
7031
7032 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
7033 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
7034
7035 if(is_large)
7036 large_dialog(quest_dlg);
7037
7038 zc_popup_dialog(quest_dlg, 0);
7039 return D_O_K;
7040 }
7041
7042 void call_vidmode_dlg();
7043 int32_t onVidMode()
7044 {
7045 call_vidmode_dlg();
7046 return D_O_K;
7047 }
7048
7049 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7050 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7051 //Added an extra statement, so that if the key is cleared to 0, the cleared
7052 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7053
7054 void load_ukeys(int32_t* arr)
7055 {
7056 arr[ukey_a] = Akey;
7057 arr[ukey_b] = Bkey;
7058 arr[ukey_s] = Skey;
7059 arr[ukey_l] = Lkey;
7060 arr[ukey_r] = Rkey;
7061 arr[ukey_p] = Pkey;
7062 arr[ukey_ex1] = Exkey1;
7063 arr[ukey_ex2] = Exkey2;
7064 arr[ukey_ex3] = Exkey3;
7065 arr[ukey_ex4] = Exkey4;
7066 arr[ukey_du] = DUkey;
7067 arr[ukey_dd] = DDkey;
7068 arr[ukey_dl] = DLkey;
7069 arr[ukey_dr] = DRkey;
7070 arr[ukey_mod1a] = cheat_modifier_keys[0];
7071 arr[ukey_mod1b] = cheat_modifier_keys[1];
7072 arr[ukey_mod2a] = cheat_modifier_keys[2];
7073 arr[ukey_mod2b] = cheat_modifier_keys[3];
7074 };
7075
7076 static const char* ukey_names[] = {
7077 "A", "B", "Start", "L", "R", "Map",
7078 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7079 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7080 "Cheat Mod R1", "Cheat Mod R2",
7081 };
7082 std::string get_ukey_name(int32_t k)
7083 {
7084 if (k < num_ukey) return ukey_names[k];
7085 return "";
7086 }
7087
7088 int32_t onKeyboard()
7089 {
7090 int32_t a = Akey;
7091 int32_t b = Bkey;
7092 int32_t s = Skey;
7093 int32_t l = Lkey;
7094 int32_t r = Rkey;
7095 int32_t p = Pkey;
7096 int32_t ex1 = Exkey1;
7097 int32_t ex2 = Exkey2;
7098 int32_t ex3 = Exkey3;
7099 int32_t ex4 = Exkey4;
7100 int32_t du = DUkey;
7101 int32_t dd = DDkey;
7102 int32_t dl = DLkey;
7103 int32_t dr = DRkey;
7104 int32_t mod1a = cheat_modifier_keys[0];
7105 int32_t mod1b = cheat_modifier_keys[1];
7106 int32_t mod2a = cheat_modifier_keys[2];
7107 int32_t mod2b = cheat_modifier_keys[3];
7108 bool done=false;
7109 int32_t ret;
7110
7111 keyboard_control_dlg[0].dp2=lfont;
7112
7113 if(is_large)
7114 large_dialog(keyboard_control_dlg);
7115
7116 while(!done)
7117 {
7118 ret = zc_popup_dialog(keyboard_control_dlg,3);
7119
7120 if(ret==3) // OK
7121 {
7122 int32_t ukeys[num_ukey];
7123 load_ukeys(ukeys);
7124 std::vector<std::string> uniqueError;
7125 for(int32_t q = 0; q < num_ukey; ++q)
7126 {
7127 for(int32_t p = q+1; p < num_ukey; ++p)
7128 {
7129 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7130 {
7131 char buf[64];
7132 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7133 std::string str(buf);
7134 uniqueError.push_back(str);
7135 }
7136 }
7137 }
7138 if(uniqueError.size() == 0)
7139 done = true;
7140 else
7141 {
7142 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7143 box_out("Cannot have duplicate keybinds!"); box_eol();
7144 for(std::vector<std::string>::iterator it = uniqueError.begin();
7145 it != uniqueError.end(); ++it)
7146 {
7147 box_out((*it).c_str()); box_eol();
7148 }
7149 box_end(true);
7150 }
7151 /* Old uniqueness check
7152 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7153 bool unique = true;
7154 addToHash(A,unique,keyhash);
7155 addToHash(B,unique,keyhash);
7156 addToHash(S,unique,keyhash);
7157 addToHash(L,unique,keyhash);
7158 addToHash(R,unique,keyhash);
7159 addToHash(P,unique,keyhash);
7160 addToHash(DU,unique,keyhash);
7161 addToHash(DD,unique,keyhash);
7162 addToHash(DL,unique,keyhash);
7163 addToHash(DR,unique,keyhash);
7164
7165 if(keyhash->find(Exkey1) == keyhash->end())
7166 {
7167 (*keyhash)[Exkey1]=true;
7168 }
7169 else
7170 {
7171 if ( Exkey1 != 0 ) unique = false;
7172 }
7173
7174 if(keyhash->find(Exkey2) == keyhash->end())
7175 {
7176 (*keyhash)[Exkey2]=true;
7177 }
7178 else
7179 {
7180 if ( Exkey2 != 0 ) unique = false;
7181 }
7182
7183 if(keyhash->find(Exkey3) == keyhash->end())
7184 {
7185 (*keyhash)[Exkey3]=true;
7186 }
7187 else
7188 {
7189 if ( Exkey3 != 0 ) unique = false;
7190 }
7191
7192 if(keyhash->find(Exkey4) == keyhash->end())
7193 {
7194 (*keyhash)[Exkey4]=true;
7195 }
7196 else
7197 {
7198 if ( Exkey4 != 0 )unique = false;
7199 }
7200 //modifier keys
7201 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7202 {
7203 (*keyhash)[cheat_modifier_keys[0]]=true;
7204 }
7205 else
7206 {
7207 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7208 }
7209 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7210 {
7211 (*keyhash)[cheat_modifier_keys[1]]=true;
7212 }
7213 else
7214 {
7215 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7216 }
7217 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7218 {
7219 (*keyhash)[cheat_modifier_keys[2]]=true;
7220 }
7221 else
7222 {
7223 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7224 }
7225 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7226 {
7227 (*keyhash)[cheat_modifier_keys[3]]=true;
7228 }
7229 else
7230 {
7231 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7232 }
7233
7234 delete keyhash;
7235
7236 if(unique)
7237 done=true;
7238 else
7239 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7240 */
7241 }
7242 else // Cancel
7243 {
7244 Akey = a;
7245 Bkey = b;
7246 Skey = s;
7247 Lkey = l;
7248 Rkey = r;
7249 Pkey = p;
7250 Exkey1 = ex1;
7251 Exkey2 = ex2;
7252 Exkey3 = ex3;
7253 Exkey4 = ex4;
7254 DUkey = du;
7255 DDkey = dd;
7256 DLkey = dl;
7257 DRkey = dr;
7258 cheat_modifier_keys[0] = mod1a;
7259 cheat_modifier_keys[1] = mod1b;
7260 cheat_modifier_keys[2] = mod2a;
7261 cheat_modifier_keys[3] = mod2b;
7262
7263 done=true;
7264 }
7265
7266 rest(1);
7267 }
7268
7269 save_game_configs();
7270 return D_O_K;
7271 }
7272
7273 int32_t onGamepad()
7274 {
7275 int32_t a = Abtn;
7276 int32_t b = Bbtn;
7277 int32_t s = Sbtn;
7278 int32_t l = Lbtn;
7279 int32_t r = Rbtn;
7280 int32_t m = Mbtn;
7281 int32_t p = Pbtn;
7282 int32_t ex1 = Exbtn1;
7283 int32_t ex2 = Exbtn2;
7284 int32_t ex3 = Exbtn3;
7285 int32_t ex4 = Exbtn4;
7286 int32_t up = DUbtn;
7287 int32_t down = DDbtn;
7288 int32_t left = DLbtn;
7289 int32_t right = DRbtn;
7290
7291 gamepad_dlg[0].dp2=lfont;
7292 if(analog_movement)
7293 gamepad_dlg[56].flags|=D_SELECTED;
7294 else
7295 gamepad_dlg[56].flags&=~D_SELECTED;
7296
7297 if(is_large)
7298 large_dialog(gamepad_dlg);
7299
7300 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7301
7302 if(ret == 4) //OK
7303 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7304 else //Cancel
7305 {
7306 Abtn = a;
7307 Bbtn = b;
7308 Sbtn = s;
7309 Lbtn = l;
7310 Rbtn = r;
7311 Mbtn = m;
7312 Pbtn = p;
7313 Exbtn1 = ex1;
7314 Exbtn2 = ex2;
7315 Exbtn3 = ex3;
7316 Exbtn4 = ex4;
7317 DUbtn = up;
7318 DDbtn = down;
7319 DLbtn = left;
7320 DRbtn = right;
7321 }
7322
7323 save_game_configs();
7324 return D_O_K;
7325 }
7326
7327 int32_t onSound()
7328 {
7329 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7330 {
7331 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7332 }
7333 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7334 {
7335 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7336 }
7337 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7338 {
7339 emusic_volume = (int32_t)FFCore.usr_music_volume;
7340 }
7341 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7342 {
7343 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7344 }
7345 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7346 {
7347 pan_style = (int32_t)FFCore.usr_panstyle;
7348 }
7349
7350 int32_t m = midi_volume;
7351 int32_t d = digi_volume;
7352 int32_t e = emusic_volume;
7353 int32_t b = zcmusic_bufsz;
7354 int32_t s = sfx_volume;
7355 int32_t p = pan_style;
7356 pan_style = vbound(pan_style,0,3);
7357
7358 sound_dlg[0].dp2=lfont;
7359
7360 if(is_large)
7361 large_dialog(sound_dlg);
7362
7363 midi_dp[1] = sound_dlg[6].x;
7364 midi_dp[2] = sound_dlg[6].y;
7365 digi_dp[1] = sound_dlg[7].x;
7366 digi_dp[2] = sound_dlg[7].y;
7367 emus_dp[1] = sound_dlg[8].x;
7368 emus_dp[2] = sound_dlg[8].y;
7369 buf_dp[1] = sound_dlg[9].x;
7370 buf_dp[2] = sound_dlg[9].y;
7371 sfx_dp[1] = sound_dlg[10].x;
7372 sfx_dp[2] = sound_dlg[10].y;
7373 pan_dp[1] = sound_dlg[11].x;
7374 pan_dp[2] = sound_dlg[11].y;
7375 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7376 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7377 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7378 sound_dlg[18].d2 = zcmusic_bufsz;
7379 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7380 sound_dlg[20].d2 = pan_style;
7381
7382 int32_t ret = zc_popup_dialog(sound_dlg,1);
7383
7384 if(ret==2)
7385 {
7386 master_volume(digi_volume,midi_volume);
7387
7388 for(int32_t i=0; i<WAV_COUNT; ++i)
7389 {
7390 //allegro assertion fails when passing in -1 as voice -DD
7391 if(sfx_voice[i] > 0)
7392 voice_set_volume(sfx_voice[i], sfx_volume);
7393 }
7394 }
7395 else
7396 {
7397 midi_volume = m;
7398 digi_volume = d;
7399 emusic_volume = e;
7400 zcmusic_bufsz = b;
7401 sfx_volume = s;
7402 pan_style = p;
7403 }
7404
7405 save_game_configs();
7406 return D_O_K;
7407 }
7408
7409 int32_t queding(char const* s1, char const* s2, char const* s3)
7410 {
7411 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7412 }
7413
7414 int32_t onQuit()
7415 {
7416 if(Playing)
7417 {
7418 int32_t ret=0;
7419
7420 if(get_bit(quest_rules, qr_NOCONTINUE))
7421 {
7422 if(standalone_mode)
7423 {
7424 ret=queding("End current game?",
7425 "The continue screen is disabled; the game",
7426 "will be reloaded from the last save.");
7427 }
7428 else
7429 {
7430 ret=queding("End current game?",
7431 "The continue screen is disabled. You will",
7432 "be returned to the file select screen.");
7433 }
7434 }
7435 else
7436 ret=queding("End current game?",NULL,NULL);
7437
7438 if(ret==1)
7439 {
7440 disableClickToFreeze=false;
7441 Quit=qQUIT;
7442
7443 // Trying to evade a door repair charge?
7444 if(repaircharge)
7445 {
7446 game->change_drupy(-repaircharge);
7447 repaircharge=0;
7448 }
7449
7450 return D_CLOSE;
7451 }
7452 }
7453
7454 return D_O_K;
7455 }
7456
7457 int32_t onTryQuitMenu()
7458 {
7459 return onTryQuit(true);
7460 }
7461
7462 int32_t onTryQuit(bool inMenu)
7463 {
7464 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7465 {
7466 if(get_bit(quest_rules,qr_OLD_F6))
7467 {
7468 if(inMenu) onQuit();
7469 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7470 }
7471 else
7472 {
7473 disableClickToFreeze=false;
7474 GameFlags |= GAMEFLAG_TRYQUIT;
7475 }
7476 return D_CLOSE;
7477 }
7478
7479 return D_O_K;
7480 }
7481
7482 int32_t onReset()
7483 {
7484 if(queding(" Reset system? ",NULL,NULL)==1)
7485 {
7486 disableClickToFreeze=false;
7487 Quit=qRESET;
7488 replay_quit();
7489 return D_CLOSE;
7490 }
7491
7492 return D_O_K;
7493 }
7494
7495 int32_t onExit()
7496 {
7497 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7498 {
7499 Quit=qEXIT;
7500 return D_CLOSE;
7501 }
7502
7503 return D_O_K;
7504 }
7505
7506 int32_t onTitle_NES()
7507 {
7508 title_version=0;
7509 return D_O_K;
7510 }
7511 int32_t onTitle_DX()
7512 {
7513 title_version=1;
7514 return D_O_K;
7515 }
7516 int32_t onTitle_25()
7517 {
7518 title_version=2;
7519 return D_O_K;
7520 }
7521
7522 int32_t onDebug()
7523 {
7524 if(debug_enabled)
7525 set_debug(!get_debug());
7526 save_game_configs();
7527 return D_O_K;
7528 }
7529
7530 int32_t onHeartBeep()
7531 {
7532 heart_beep=!heart_beep;
7533 save_game_configs();
7534 return D_O_K;
7535 }
7536
7537 int32_t onSaveIndicator()
7538 {
7539 use_save_indicator=!use_save_indicator;
7540 save_game_configs();
7541 return D_O_K;
7542 }
7543
7544 int32_t onEpilepsy()
7545 {
7546 if(jwin_alert3(
7547 "Epilepsy Flash Reduction",
7548 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7549 "Disabling this will restore standard flash and wavy behaviour.",
7550 "Proceed?",
7551 "&Yes",
7552 "&No",
7553 NULL,
7554 'y',
7555 'n',
7556 0,
7557 lfont) == 1)
7558 {
7559 if ( epilepsyFlashReduction ) epilepsyFlashReduction = 0;
7560 else epilepsyFlashReduction = 1;
7561 set_config_int("zeldadx","checked_epilepsy",1);
7562 save_game_configs();
7563 }
7564 return D_O_K;
7565 }
7566
7567 int32_t onTriforce()
7568 {
7569 for(int32_t i=0; i<MAXINITTABS; ++i)
7570 {
7571 init_tabs[i].flags&=~D_SELECTED;
7572 }
7573
7574 init_tabs[3].flags=D_SELECTED;
7575 return onCheatConsole();
7576 /*triforce_dlg[0].dp2=lfont;
7577 for(int32_t i=1; i<=8; i++)
7578 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7579
7580 if(zc_popup_dialog (triforce_dlg,-1)==9)
7581 {
7582 for(int32_t i=1; i<=8; i++)
7583 {
7584 game->lvlitems[i] &= ~liTRIFORCE;
7585 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7586 }
7587 }
7588 return D_O_K;*/
7589 }
7590
7591 bool rc = false;
7592 /*
7593 int32_t onEquipment()
7594 {
7595 for (int32_t i=0; i<MAXINITTABS; ++i)
7596 {
7597 init_tabs[i].flags&=~D_SELECTED;
7598 }
7599 init_tabs[0].flags=D_SELECTED;
7600 return onCheatConsole();
7601 }
7602 */
7603
7604 int32_t onItems()
7605 {
7606 for(int32_t i=0; i<MAXINITTABS; ++i)
7607 {
7608 init_tabs[i].flags&=~D_SELECTED;
7609 }
7610
7611 init_tabs[1].flags=D_SELECTED;
7612 return onCheatConsole();
7613 }
7614
7615 static DIALOG getnum_dlg[] =
7616 {
7617 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7618 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7619 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7620 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7621 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7622 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7623 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7624 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7625 };
7626
7627 int32_t getnumber(const char *prompt,int32_t initialval)
7628 {
7629 char buf[20];
7630 sprintf(buf,"%d",initialval);
7631 getnum_dlg[0].dp=(void *)prompt;
7632 getnum_dlg[0].dp2=lfont;
7633 getnum_dlg[2].dp=buf;
7634
7635 if(is_large)
7636 large_dialog(getnum_dlg);
7637
7638 if(zc_popup_dialog(getnum_dlg,2)==3)
7639 return atoi(buf);
7640
7641 return initialval;
7642 }
7643
7644 int32_t onLife()
7645 {
7646 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7647 cheats_enqueue(Cheat::Life, value);
7648 return D_O_K;
7649 }
7650
7651 int32_t onHeartC()
7652 {
7653 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7654 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7655 cheats_enqueue(Cheat::MaxLife, max_life);
7656 cheats_enqueue(Cheat::Life, life);
7657 return D_O_K;
7658 }
7659
7660 int32_t onMagicC()
7661 {
7662 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7663 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7664 cheats_enqueue(Cheat::MaxMagic, max_magic);
7665 cheats_enqueue(Cheat::Magic, magic);
7666 return D_O_K;
7667 }
7668
7669 int32_t onRupies()
7670 {
7671 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7672 cheats_enqueue(Cheat::Rupies, value);
7673 return D_O_K;
7674 }
7675
7676 int32_t onMaxBombs()
7677 {
7678 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7679 cheats_enqueue(Cheat::MaxBombs, value);
7680 cheats_enqueue(Cheat::Bombs, value);
7681 return D_O_K;
7682 }
7683
7684 int32_t onRefillLife()
7685 {
7686 cheats_enqueue(Cheat::Life, game->get_maxlife());
7687 return D_O_K;
7688 }
7689 int32_t onRefillMagic()
7690 {
7691 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7692 return D_O_K;
7693 }
7694 int32_t onClock()
7695 {
7696 cheats_enqueue(Cheat::Clock);
7697 return D_O_K;
7698 }
7699
7700 int32_t onQstPath()
7701 {
7702 char path[2048];
7703
7704 chop_path(qstdir);
7705 strcpy(path,qstdir);
7706
7707 go();
7708
7709 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7710 {
7711 chop_path(path);
7712 fix_filename_case(path);
7713 fix_filename_slashes(path);
7714 strcpy(qstdir,path);
7715 strcpy(qstpath,qstdir);
7716 }
7717
7718 comeback();
7719 return D_O_K;
7720 }
7721
7722 #include "dialog/cheat_dialog.h"
7723 int32_t onCheat()
7724 {
7725 call_setcheat_dialog();
7726 game->set_cheat(maxcheat);
7727 if(cheat) game->did_cheat(true);
7728 return D_O_K;
7729 }
7730
7731 int32_t onCheatRupies()
7732 {
7733 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7734 return D_O_K;
7735 }
7736
7737 int32_t onCheatArrows()
7738 {
7739 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7740 return D_O_K;
7741 }
7742
7743 int32_t onCheatBombs()
7744 {
7745 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7746 return D_O_K;
7747 }
7748
7749 // *** screen saver
7750
7751 955876 int32_t after_time()
7752 {
7753
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(ss_enable == 0)
7754 return INT_MAX;
7755
7756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 0)
7757 return 5 * 60;
7758
7759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 3)
7760 return ss_after * 15 * 60;
7761
7762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 13)
7763 return (ss_after - 3) * 60 * 60;
7764
7765 955876 return MAX_IDLE + 1;
7766 955876 }
7767
7768 static const char *after_str[15] =
7769 {
7770 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7771 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7772 "Never"
7773 };
7774
7775 const char *after_list(int32_t index, int32_t *list_size)
7776 {
7777 if(index < 0)
7778 {
7779 *list_size = 15;
7780 return NULL;
7781 }
7782
7783 return after_str[index];
7784 }
7785
7786 11 static ListData after__list(after_list, &font);
7787
7788 static DIALOG scrsaver_dlg[] =
7789 {
7790 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7791 11 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7792 11 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7793 11 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7794 11 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7795 11 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7796 11 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7797 11 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7798 11 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7799 11 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7800 11 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7801 11 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7802 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7803 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7804 };
7805
7806 int32_t onScreenSaver()
7807 {
7808 scrsaver_dlg[0].dp2=lfont;
7809 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = ss_after;
7810 scrsaver_dlg[6].d2 = ss_speed;
7811 scrsaver_dlg[7].d2 = ss_density;
7812
7813 if(is_large)
7814 large_dialog(scrsaver_dlg);
7815
7816 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7817
7818 if(ret == 8 || ret == 9)
7819 {
7820 ss_after = scrsaver_dlg[5].d1;
7821 ss_speed = scrsaver_dlg[6].d2;
7822 ss_density = scrsaver_dlg[7].d2;
7823 }
7824
7825 if(ret == 9)
7826 // preview Screen Saver
7827 {
7828 clear_keybuf();
7829 scare_mouse();
7830 Matrix(ss_speed, ss_density, 30);
7831 system_pal();
7832 unscare_mouse();
7833 }
7834
7835 return D_O_K;
7836 }
7837
7838 /***** Menus *****/
7839
7840 static MENU game_menu[] =
7841 {
7842 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7843 { (char *)"", NULL, NULL, 0, NULL },
7844 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7845 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7846 { (char *)"", NULL, NULL, 0, NULL },
7847 #ifdef __EMSCRIPTEN__
7848 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7849 #elif defined(ALLEGRO_MACOSX)
7850 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7851 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7852 #else
7853 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7854 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7855 #endif
7856 { NULL, NULL, NULL, 0, NULL }
7857 };
7858
7859 static MENU title_menu[] =
7860 {
7861 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7862 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7863 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7864 { NULL, NULL, NULL, 0, NULL }
7865 };
7866
7867 static MENU snapshot_format_menu[] =
7868 {
7869 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7870 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7871 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7872 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7873 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7874 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7875 { NULL, NULL, NULL, 0, NULL }
7876 };
7877
7878 static MENU controls_menu[] =
7879 {
7880 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7881 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7882 { NULL, NULL, NULL, 0, NULL }
7883 };
7884
7885 static MENU name_entry_mode_menu[] =
7886 {
7887 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7888 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7889 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7890 { NULL, NULL, NULL, 0, NULL }
7891 };
7892
7893 static void set_controls_menu_active()
7894 {
7895
7896 }
7897
7898 static MENU settings_menu[] =
7899 {
7900 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7901 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7902 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7903 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7904 { (char *)"", NULL, NULL, 0, NULL },
7905 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7906 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7907 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7908 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7909 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7910 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7911 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7912 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7913 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7914 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7915 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7916 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7917 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7918 { (char *)"", NULL, NULL, 0, NULL },
7919 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7920 { (char *)"", NULL, NULL, 0, NULL },
7921 { NULL, NULL, NULL, 0, NULL }
7922 };
7923
7924
7925 static MENU misc_menu[] =
7926 {
7927 { (char *)"&About...", onAbout, NULL, 0, NULL },
7928 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7929 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7930 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7931 { (char *)"", NULL, NULL, 0, NULL },
7932 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7933 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7934 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7935 { (char *)"", NULL, NULL, 0, NULL },
7936 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7937 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7938 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7939 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7940 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7941 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7942 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7943 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7944
7945 { NULL, NULL, NULL, 0, NULL }
7946 };
7947
7948 static MENU refill_menu[] =
7949 {
7950 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7951 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7952 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7953 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7954 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7955 { NULL, NULL, NULL, 0, NULL }
7956 };
7957
7958 static MENU show_menu[] =
7959 {
7960 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7961 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7962 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7963 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7964 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7965 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7966 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7967 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7968 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7969 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7970 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7971 { (char *)"", NULL, NULL, 0, NULL },
7972 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7973 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7974 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7975 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7976 { NULL, NULL, NULL, 0, NULL }
7977 };
7978
7979 static MENU cheat_menu[] =
7980 {
7981 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7982 { (char *)"", NULL, NULL, 0, NULL },
7983 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7984 { (char *)"", NULL, NULL, 0, NULL },
7985 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7986 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7987 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7988 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7989 { (char *)"", NULL, NULL, 0, NULL },
7990 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7991 { (char *)"", NULL, NULL, 0, NULL },
7992 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7993 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7994 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7995 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7996 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7997 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7998 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7999 { NULL, NULL, NULL, 0, NULL }
8000 };
8001
8002 static MENU fixes_menu[] =
8003 {
8004 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
8005 { NULL, NULL, NULL, 0, NULL }
8006 };
8007
8008 #if DEVLEVEL > 0
8009 int32_t devLogging();
8010 int32_t devDebug();
8011 int32_t devTimestmp();
8012 #if DEVLEVEL > 1
8013 int32_t setCheat();
8014 #endif //DEVLEVEL > 1
8015 static MENU dev_menu[] =
8016 {
8017 { (char *)"&Force Error Log", devLogging, NULL, D_SELECTED, NULL },
8018 { (char *)"&Extra Debug Log", devDebug, NULL, D_SELECTED, NULL },
8019 { (char *)"&Timestamp Log", devTimestmp, NULL, D_SELECTED, NULL },
8020 #if DEVLEVEL > 1
8021 { (char *)"", NULL, NULL, 0, NULL },
8022 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8023 #endif //DEVLEVEL > 1
8024 { NULL, NULL, NULL, 0, NULL }
8025 };
8026 int32_t devLogging()
8027 {
8028 dev_logging = !dev_logging;
8029 dev_menu[0].flags = dev_logging ? D_SELECTED : 0;
8030 return D_O_K;
8031 }
8032 int32_t devDebug()
8033 {
8034 dev_debug = !dev_debug;
8035 dev_menu[1].flags = dev_debug ? D_SELECTED : 0;
8036 return D_O_K;
8037 }
8038 int32_t devTimestmp()
8039 {
8040 dev_timestmp = !dev_timestmp;
8041 dev_menu[2].flags = dev_timestmp ? D_SELECTED : 0;
8042 return D_O_K;
8043 }
8044 #if DEVLEVEL > 1
8045 int32_t setCheat()
8046 {
8047 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8048 return D_O_K;
8049 }
8050 #endif //DEVLEVEL > 1
8051 #endif //DEVLEVEL > 0
8052
8053 MENU the_player_menu[] =
8054 {
8055 { (char *)"&Game", NULL, game_menu, 0, NULL },
8056 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8057 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8058 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8059 #if DEVLEVEL > 0
8060 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8061 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8062 { NULL, NULL, NULL, 0, NULL }
8063 #else
8064 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8065 { NULL, NULL, NULL, 0, NULL }
8066 #endif
8067 };
8068
8069 MENU the_player_menu2[] =
8070 {
8071 { (char *)"&Game", NULL, game_menu, 0, NULL },
8072 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8073 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8074
8075 #if DEVLEVEL > 0
8076 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8077 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8078 { NULL, NULL, NULL, 0, NULL }
8079 #else
8080 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8081 { NULL, NULL, NULL, 0, NULL }
8082 #endif
8083
8084 };
8085
8086 int32_t onMIDIPatch()
8087 {
8088 if(jwin_alert3(
8089 "Toggle Windows MIDI Fix",
8090 "This action will change whether ZC Player auto-restarts a MIDI at its",
8091 "last index if you move ZC Player out of focus, then back into focus.",
8092 "Proceed?",
8093 "&Yes",
8094 "&No",
8095 NULL,
8096 'y',
8097 'n',
8098 0,
8099 lfont) == 1)
8100 {
8101 if (midi_patch_fix) midi_patch_fix = 0;
8102
8103 else midi_patch_fix = 1;
8104
8105 }
8106 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8107 save_game_configs();
8108 return D_O_K;
8109 }
8110
8111 int32_t onKeyboardEntry()
8112 {
8113 NameEntryMode=0;
8114 return D_O_K;
8115 }
8116
8117 int32_t onLetterGridEntry()
8118 {
8119 NameEntryMode=1;
8120 return D_O_K;
8121 }
8122
8123 int32_t onExtLetterGridEntry()
8124 {
8125 NameEntryMode=2;
8126 return D_O_K;
8127 }
8128
8129 static BITMAP* oldscreen;
8130 int32_t onFullscreenMenu()
8131 {
8132 // super hacks
8133 screen = oldscreen;
8134 if (onFullscreen() == D_REDRAW)
8135 {
8136 oldscreen = screen;
8137 }
8138 screen = menu_bmp;
8139 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8140 return D_O_K;
8141 }
8142
8143 11 void fix_menu()
8144 {
8145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!debug_enabled)
8146 11 settings_menu[18].text = NULL;
8147 11 }
8148
8149 static DIALOG system_dlg[] =
8150 {
8151 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8152 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8153 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8154 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8155 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8156 #ifndef ALLEGRO_MACOSX
8157 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8159 #else
8160 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8161 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8162 #endif
8163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8164 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8165 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8166 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8167 };
8168
8169 static DIALOG system_dlg2[] =
8170 {
8171 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8172 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8173 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8174 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8175 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8176 #ifndef ALLEGRO_MACOSX
8177 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8178 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8179 #else
8180 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8181 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8182 #endif
8183 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8184 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8185 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8186 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8187 };
8188
8189 void reset_snapshot_format_menu()
8190 {
8191 for(int32_t i=0; i<ssfmtMAX; ++i)
8192 {
8193 snapshot_format_menu[i].flags=0;
8194 }
8195 }
8196
8197 int32_t onSetSnapshotFormat()
8198 {
8199 switch(active_menu->text[1])
8200 {
8201 case 'B': //"&BMP"
8202 SnapshotFormat=0;
8203 break;
8204
8205 case 'G': //"&GIF"
8206 SnapshotFormat=1;
8207 break;
8208
8209 case 'J': //"&JPG"
8210 SnapshotFormat=2;
8211 break;
8212
8213 case 'P': //"&PNG"
8214 SnapshotFormat=3;
8215 break;
8216
8217 case 'C': //"PC&X"
8218 SnapshotFormat=4;
8219 break;
8220
8221 case 'T': //"&TGA"
8222 SnapshotFormat=5;
8223 break;
8224
8225 case 'L': //"&LBM"
8226 SnapshotFormat=6;
8227 break;
8228 }
8229
8230 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8231 return D_O_K;
8232 }
8233
8234
8235 12 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8236 {
8237 PALETTE tmp;
8238
8239
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<256; i++)
8240 {
8241 3072 tmp[i].r=r;
8242 3072 tmp[i].g=g;
8243 3072 tmp[i].b=b;
8244 3072 }
8245
8246 12 fade_interpolate(src,tmp,dest,pos,from,to);
8247 12 }
8248
8249 12 void system_pal()
8250 {
8251 12 is_sys_pal = true;
8252 static PALETTE pal;
8253 12 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8254
8255 // set up the grayscale palette
8256
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 12 times.
780 for(int32_t i=128; i<192; i++)
8257 {
8258 768 pal[i].r = i-128;
8259 768 pal[i].g = i-128;
8260 768 pal[i].b = i-128;
8261 768 }
8262 12 load_colorset(gui_colorset, pal);
8263
8264 12 color_layer(pal, pal, 24,16,16, 28, 128,191);
8265
8266
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t i=0; i<256; i+=2)
8267 {
8268 1536 int32_t v = (i>>3)+2;
8269 1536 int32_t c = (i>>3)+192;
8270 1536 pal[c] = _RGB(v,v,v+(v>>1));
8271 /*
8272 if(i<240)
8273 {
8274 _allegro_hline(tmp_scr,0,i,319,c);
8275 _allegro_hline(tmp_scr,0,i+1,319,c);
8276 }
8277 */
8278 1536 }
8279
8280 // draw the vertical screen gradient
8281
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 12 times.
2892 for(int32_t i=0; i<240; ++i)
8282 {
8283 2880 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8284 2880 }
8285
8286 /*
8287 palrstart= 10*63/255; palrend=166*63/255;
8288 palgstart= 36*63/255; palgend=202*63/255;
8289 palbstart=106*63/255; palbend=240*63/255;
8290 paldivs=32;
8291 for(int32_t i=0; i<paldivs; i++)
8292 {
8293 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8294 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8295 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8296 }
8297 */
8298 12 BITMAP *panorama = create_bitmap_ex(8,256,224);
8299 int32_t ts_height, ts_start;
8300
8301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8302 {
8303 clear_to_color(panorama,0);
8304 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8305 ts_height=224-passive_subscreen_height;
8306 ts_start=28;
8307 }
8308 else
8309 {
8310 12 blit(framebuf,panorama,0,0,0,0,256,224);
8311 12 ts_height=224;
8312 12 ts_start=0;
8313 }
8314
8315 // gray scale the current frame
8316
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 12 times.
2700 for(int32_t y=0; y<ts_height; y++)
8317 {
8318
2/2
✓ Branch 0 taken 688128 times.
✓ Branch 1 taken 2688 times.
690816 for(int32_t x=0; x<256; x++)
8319 {
8320 688128 int32_t c = panorama->line[y+ts_start][x];
8321
2/2
✓ Branch 0 taken 687647 times.
✓ Branch 1 taken 481 times.
688128 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8322 688128 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8323 688128 }
8324 2688 }
8325
8326 12 destroy_bitmap(panorama);
8327
8328 // display everything
8329 12 vsync();
8330 12 hw_palette = &pal;
8331 12 update_hw_pal = true;
8332
8333 // sys_pal = pal;
8334 12 memcpy(sys_pal,pal,sizeof(pal));
8335 12 }
8336
8337 void system_pal2()
8338 {
8339 is_sys_pal = true;
8340 static PALETTE RAMpal2;
8341 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8342
8343 /* Windows 2000 colors
8344 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8345 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8346 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8347 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8348 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8349 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8350 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8351 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8352
8353 byte palrstart= 10*63/255, palrend=166*63/255,
8354 palgstart= 36*63/255, palgend=202*63/255,
8355 palbstart=106*63/255, palbend=240*63/255,
8356 paldivs=7;
8357 for(int32_t i=0; i<paldivs; i++)
8358 {
8359 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8360 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8361 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8362 }
8363 */
8364
8365 /* Windows 98 colors
8366 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8367 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8368 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8369 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8370 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8371 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8372 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8373 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8374
8375 byte palrstart= 0*63/255, palrend=166*63/255,
8376 palgstart= 0*63/255, palgend=202*63/255,
8377 palbstart=128*63/255, palbend=240*63/255,
8378 paldivs=7;
8379 for(int32_t i=0; i<paldivs; i++)
8380 {
8381 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8382 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8383 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8384 }
8385 */
8386
8387 /* Windows 99 colors
8388 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8389 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8390 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8391 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8392 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8393 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8394 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8395 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8396 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8397
8398 byte palrstart= 0*63/255, palrend=166*63/255,
8399 palgstart= 0*63/255, palgend=202*63/255,
8400
8401 palbstart=128*63/255, palbend=240*63/255,
8402 paldivs=6;
8403 for(int32_t i=0; i<paldivs; i++)
8404 {
8405 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8406 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8407 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8408 }
8409 */
8410
8411
8412
8413 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8414 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8415 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8416 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8417 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8418 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8419 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8420 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8421 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8422
8423 byte palrstart= 0*63/255, palrend=166*63/255,
8424 palgstart= 0*63/255, palgend=202*63/255,
8425 palbstart=128*63/255, palbend=240*63/255,
8426 paldivs=6;
8427
8428 for(int32_t i=0; i<paldivs; i++)
8429 {
8430 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8431 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8432 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8433 }
8434
8435 gui_bg_color=jwin_pal[jcBOX];
8436 gui_fg_color=jwin_pal[jcBOXFG];
8437
8438 jwin_set_colors(jwin_pal);
8439
8440
8441 // set up the new palette
8442 for(int32_t i=128; i<192; i++)
8443 {
8444 RAMpal2[i].r = i-128;
8445 RAMpal2[i].g = i-128;
8446 RAMpal2[i].b = i-128;
8447 }
8448
8449 /*
8450 for(int32_t i=0; i<64; i++)
8451 {
8452 RAMpal2[128+i] = _RGB(i,i,i)1));
8453 }
8454 */
8455
8456 /*
8457
8458 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8459 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8460 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8461 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8462 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8463 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8464 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8465
8466 gui_fg_color=vc(14);
8467 gui_bg_color=vc(1);
8468
8469 jwin_set_colors(jwin_pal);
8470 */
8471
8472 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8473
8474 // set up the colors for the vertical screen gradient
8475 for(int32_t i=0; i<256; i+=2)
8476 {
8477 int32_t v = (i>>3)+2;
8478 int32_t c = (i>>3)+192;
8479 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8480
8481 /*
8482 if(i<240)
8483 {
8484 _allegro_hline(tmp_scr,0,i,319,c);
8485 _allegro_hline(tmp_scr,0,i+1,319,c);
8486 }
8487 */
8488 }
8489
8490 // hw_palette = &RAMpal;
8491 // update_hw_pal = true;
8492
8493 for(int32_t i=0; i<240; ++i)
8494 {
8495 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8496 }
8497
8498 /*
8499 byte palrstart= 10*63/255, palrend=166*63/255,
8500 palgstart= 36*63/255, palgend=202*63/255,
8501 palbstart=106*63/255, palbend=240*63/255,
8502 paldivs=32;
8503 for(int32_t i=0; i<paldivs; i++)
8504 {
8505 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8506 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8507 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8508 }
8509 */
8510 BITMAP *panorama = create_bitmap_ex(8,256,224);
8511 int32_t ts_height, ts_start;
8512
8513 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8514 {
8515 clear_to_color(panorama,0);
8516 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8517 ts_height=224-passive_subscreen_height;
8518 ts_start=28;
8519 }
8520 else
8521 {
8522 blit(framebuf,panorama,0,0,0,0,256,224);
8523 ts_height=224;
8524 ts_start=0;
8525 }
8526
8527 // gray scale the current frame
8528 for(int32_t y=0; y<ts_height; y++)
8529 {
8530 for(int32_t x=0; x<256; x++)
8531 {
8532 int32_t c = panorama->line[y+ts_start][x];
8533 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8534 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8535 }
8536 }
8537
8538 destroy_bitmap(panorama);
8539
8540 // display everything
8541 vsync();
8542 hw_palette = &RAMpal2;
8543 update_hw_pal = true;
8544
8545 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8546
8547 // sys_pal = pal;
8548 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8549 }
8550
8551 static uint32_t entered_sys_pal = 0;
8552 1 void enter_sys_pal()
8553 {
8554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(is_sys_pal)
8555 {
8556 if(entered_sys_pal)
8557 ++entered_sys_pal;
8558 return;
8559 }
8560 1 system_pal();
8561 1 ++entered_sys_pal;
8562 1 }
8563 1 void exit_sys_pal()
8564 {
8565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(entered_sys_pal)
8566 {
8567
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!--entered_sys_pal)
8568 {
8569 1 game_pal();
8570 1 }
8571 1 }
8572 1 }
8573
8574 void switch_out_callback()
8575 {
8576 if (pause_in_background)
8577 {
8578 callback_switchin = 3;
8579 return;
8580 }
8581
8582 #ifdef _WIN32
8583 if(midi_patch_fix==0 || currmidi==-1)
8584 return;
8585
8586
8587 paused_midi_pos = midi_pos;
8588 zc_stop_midi();
8589 midi_paused=true;
8590 midi_suspended = midissuspHALTED;
8591 #endif
8592 }
8593
8594 void switch_in_callback()
8595 {
8596 zc_update_builtin_font();
8597
8598 if(pause_in_background)
8599 {
8600 return;
8601 }
8602
8603 #ifdef _WIN32
8604 if(midi_patch_fix==0 || currmidi==-1)
8605 return;
8606
8607 else
8608 {
8609 callback_switchin = 1;
8610 midi_suspended = midissuspRESUME;
8611 }
8612 #endif
8613 }
8614
8615 55 void game_pal()
8616 {
8617 55 is_sys_pal = false;
8618 55 entered_sys_pal = 0;
8619 55 clear_to_color(screen,BLACK);
8620 55 hw_palette = &RAMpal;
8621 55 update_hw_pal = true;
8622 55 }
8623
8624 static char bar_str[] = "";
8625
8626 1 void music_pause()
8627 {
8628 //al_pause_duh(tmplayer);
8629 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8630 1 zc_midi_pause();
8631 1 midi_paused=true;
8632 1 }
8633
8634 void music_resume()
8635 {
8636 //al_resume_duh(tmplayer);
8637 zcmusic_pause(zcmusic, ZCM_RESUME);
8638 zc_midi_resume();
8639 midi_paused=false;
8640 }
8641
8642 613 void music_stop()
8643 {
8644 //al_stop_duh(tmplayer);
8645 //unload_duh(tmusic);
8646 //tmusic=NULL;
8647 //tmplayer=NULL;
8648 613 zcmusic_stop(zcmusic);
8649 613 zcmusic_unload_file(zcmusic);
8650 613 zc_stop_midi();
8651 613 midi_paused=false;
8652 613 currmidi=-1;
8653 613 }
8654
8655 void System()
8656 {
8657 mouse_down=gui_mouse_b();
8658 music_pause();
8659 pause_all_sfx();
8660 MenuOpen = true;
8661 system_pal();
8662 // FONT *oldfont=font;
8663 // font=tfont;
8664
8665 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8666 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8667
8668 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8669 #if DEVLEVEL > 1
8670 dev_menu[4].flags = Playing ? 0 : D_DISABLED;
8671 #endif
8672 game_menu[3].flags =
8673 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8674 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8675 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8676 clear_keybuf();
8677 show_mouse(screen);
8678
8679 DIALOG_PLAYER *p;
8680
8681 clear_bitmap(menu_bmp);
8682 oldscreen = screen;
8683 screen = menu_bmp;
8684
8685 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8686 {
8687 p = init_dialog(system_dlg2,-1);
8688 }
8689 else
8690 {
8691 p = init_dialog(system_dlg,-1);
8692 }
8693
8694 // drop the menu on startup if menu button pressed
8695 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8696 simulate_keypress(KEY_G << 8);
8697
8698 do
8699 {
8700 if(close_button_quit)
8701 {
8702 close_button_quit = false;
8703 f_Quit(qEXIT);
8704 if(Quit) break;
8705 }
8706 rest(17);
8707
8708 if(mouse_down && !gui_mouse_b())
8709 mouse_down=0;
8710
8711 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8712 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8713 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8714
8715 settings_menu[0].flags = replay_is_replaying() ? D_DISABLED : 0;
8716 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8717 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8718 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8719 settings_menu[8].flags = NESquit?D_SELECTED:0;
8720 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8721 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8722 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8723 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8724 settings_menu[13].flags = volkeys?D_SELECTED:0;
8725 //Epilepsy Prevention
8726 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8727
8728 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8729 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8730 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8731
8732 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8733 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8734
8735 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8736 cheat_menu[0].flags = 0;
8737 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8738 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8739 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8740 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8741 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8742 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8743 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8744 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8745 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8746
8747 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8748 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8749 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8750 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8751 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8752 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8753 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8754 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8755 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8756 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8757 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8758 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8759 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8760 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8761 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8762
8763 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8764 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8765
8766 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8767 (char *)"Disable recording new saves" :
8768 (char *)"Enable recording new saves";
8769 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8770 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8771 (char *)"Stop recording" :
8772 (char *)"Stop replaying";
8773 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8774
8775 reset_snapshot_format_menu();
8776 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8777
8778 if(debug_enabled)
8779 {
8780 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8781 }
8782
8783 if(gui_mouse_b() && !mouse_down)
8784 break;
8785
8786 // press menu to drop the menu
8787 if(rMbtn())
8788 simulate_keypress(KEY_G << 8);
8789
8790 if(input_idle(true) > after_time())
8791 // run Screeen Saver
8792 {
8793 // Screen saver enabled for now.
8794 clear_keybuf();
8795 scare_mouse();
8796 Matrix(ss_speed, ss_density, 0);
8797 system_pal();
8798 unscare_mouse();
8799 broadcast_dialog_message(MSG_DRAW, 0);
8800 }
8801
8802 update_hw_screen();
8803 }
8804 while(update_dialog(p));
8805
8806 screen = oldscreen;
8807
8808 // font=oldfont;
8809 mouse_down=gui_mouse_b();
8810 shutdown_dialog(p);
8811 show_mouse(NULL);
8812 MenuOpen = false;
8813 if(Quit)
8814 {
8815 kill_sfx();
8816 music_stop();
8817 update_hw_screen();
8818 }
8819 else
8820 {
8821 game_pal();
8822 music_resume();
8823 resume_all_sfx();
8824
8825 if(rc)
8826 ringcolor(false);
8827 }
8828
8829 eat_buttons();
8830
8831 rc=false;
8832 clear_keybuf();
8833 // text_mode(0);
8834 }
8835
8836 11 void fix_dialogs()
8837 {
8838 11 jwin_center_dialog(about_dlg);
8839 11 jwin_center_dialog(gamepad_dlg);
8840 11 jwin_center_dialog(credits_dlg);
8841 11 jwin_center_dialog(gamemode_dlg);
8842 11 jwin_center_dialog(getnum_dlg);
8843 11 jwin_center_dialog(goto_dlg);
8844 11 jwin_center_dialog(keyboard_control_dlg);
8845 11 jwin_center_dialog(midi_dlg);
8846 11 jwin_center_dialog(quest_dlg);
8847 11 jwin_center_dialog(scrsaver_dlg);
8848 11 jwin_center_dialog(sound_dlg);
8849 11 jwin_center_dialog(triforce_dlg);
8850
8851 // digi_dp[1] += scrx;
8852 // digi_dp[2] += scry;
8853 // midi_dp[1] += scrx;
8854 // midi_dp[2] += scry;
8855 // pan_dp[1] += scrx;
8856 // pan_dp[2] += scry;
8857 // emus_dp[1] += scrx;
8858 // emus_dp[2] += scry;
8859 // buf_dp[1] += scrx;
8860 // buf_dp[2] += scry;
8861 // sfx_dp[1] += scrx;
8862 // sfx_dp[2] += scry;
8863 11 }
8864
8865 /*****************************/
8866 /**** Custom Sound System ****/
8867 /*****************************/
8868
8869 229 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8870 {
8871
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 120 times.
229 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8872 }
8873
8874 // Run an NSF, or a MIDI if the NSF is missing somehow.
8875 18 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8876 {
8877 18 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8878
8879 // Found it
8880
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(newzcmusic!=NULL)
8881 {
8882 18 zcmusic_stop(zcmusic);
8883 18 zcmusic_unload_file(zcmusic);
8884 18 zc_stop_midi();
8885
8886 18 zcmusic=newzcmusic;
8887 18 zcmusic_play(zcmusic, emusic_volume);
8888
8889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(track>0)
8890 18 zcmusic_change_track(zcmusic,track);
8891
8892 18 return true;
8893 }
8894
8895 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8896 else if(midi>-1000)
8897 jukebox(midi);
8898
8899 return false;
8900 18 }
8901
8902 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8903 {
8904 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8905 // Found it
8906 if(newzcmusic!=NULL)
8907 {
8908 zcmusic_stop(zcmusic);
8909 zcmusic_unload_file(zcmusic);
8910 zc_stop_midi();
8911
8912 zcmusic=newzcmusic;
8913 zcmusic_play(zcmusic, emusic_volume);
8914
8915 if(track>0)
8916 zcmusic_change_track(zcmusic,track);
8917
8918 return true;
8919 }
8920
8921 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8922 else if(midi>-1000)
8923 jukebox(midi);
8924
8925 return false;
8926 }
8927
8928 int32_t get_zcmusicpos()
8929 {
8930 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8931 return debugtracething;
8932 return 0;
8933 }
8934
8935 void set_zcmusicpos(int32_t position)
8936 {
8937 zcmusic_set_curpos(zcmusic, position);
8938 }
8939
8940 void set_zcmusicspeed(int32_t speed)
8941 {
8942 int32_t newspeed = vbound(speed, 0, 10000);
8943 zcmusic_set_speed(zcmusic, newspeed);
8944 }
8945
8946 109 void jukebox(int32_t index,int32_t loop)
8947 {
8948 109 music_stop();
8949
8950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(index<0) index=MAXMIDIS-1;
8951
8952
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(index>=MAXMIDIS) index=0;
8953
8954 109 music_stop();
8955
8956 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8957 // stuck notes when a song stops. This fixes it.
8958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(strcmp(midi_driver->name, "DIGMID")==0)
8959 zc_set_volume(0, 0);
8960
8961 109 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8962 109 zc_play_midi((MIDI*)tunes[index].data,loop);
8963
8964
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 11 times.
109 if(tunes[index].start>0)
8965 11 zc_midi_seek(tunes[index].start);
8966
8967 109 midi_loop_start = tunes[index].loop_start;
8968 109 midi_loop_end = tunes[index].loop_end;
8969
8970 109 currmidi=index;
8971 109 master_volume(digi_volume,midi_volume);
8972 109 midi_paused=false;
8973 109 }
8974
8975 894 void jukebox(int32_t index)
8976 {
8977
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 if(index<0) index=MAXMIDIS-1;
8978
8979
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 if(index>=MAXMIDIS) index=0;
8980
8981 // do nothing if it's already playing
8982
3/4
✓ Branch 0 taken 785 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 785 times.
✗ Branch 3 not taken.
894 if(index==currmidi && midi_pos>=0)
8983 {
8984 785 midi_paused=false;
8985 785 return;
8986 }
8987
8988 109 jukebox(index,tunes[index].loop);
8989 894 }
8990
8991 1353 void play_DmapMusic()
8992 {
8993 static char tfile[2048];
8994 static int32_t ttrack=0;
8995 1353 bool domidi=false;
8996
8997
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 882 times.
1353 if(DMaps[currdmap].tmusic[0]!=0)
8998 {
8999
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
856 if(zcmusic==NULL ||
9000
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
9001
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
9002 {
9003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(zcmusic != NULL)
9004 {
9005 zcmusic_stop(zcmusic);
9006 zcmusic_unload_file(zcmusic);
9007 zcmusic = NULL;
9008 }
9009
9010 86 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9011
9012
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(zcmusic!=NULL)
9013 {
9014 86 zc_stop_midi();
9015 86 strcpy(tfile,DMaps[currdmap].tmusic);
9016 86 zcmusic_play(zcmusic, emusic_volume);
9017 86 int32_t temptracks=0;
9018 86 temptracks=zcmusic_get_tracks(zcmusic);
9019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
9020 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9021 86 zcmusic_change_track(zcmusic,ttrack);
9022 86 }
9023 else
9024 {
9025 tfile[0] = 0;
9026 domidi=true;
9027 }
9028 86 }
9029 471 }
9030 else
9031 {
9032 882 domidi=true;
9033 }
9034
9035
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 882 times.
1353 if(domidi)
9036 {
9037 882 int32_t m=DMaps[currdmap].midi;
9038
9039
3/4
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
882 switch(m)
9040 {
9041 case 1:
9042 80 jukebox(ZC_MIDI_OVERWORLD);
9043 80 break;
9044
9045 case 2:
9046 9 jukebox(ZC_MIDI_DUNGEON);
9047 9 break;
9048
9049 case 3:
9050 jukebox(ZC_MIDI_LEVEL9);
9051 break;
9052
9053 default:
9054
3/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 786 times.
793 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9055 786 jukebox(m+MIDIOFFSET_DMAP);
9056 else
9057 7 music_stop();
9058 793 }
9059 882 }
9060 1353 }
9061
9062 1353 void playLevelMusic()
9063 {
9064 1353 int32_t m=tmpscr->screen_midi;
9065
9066
1/6
✓ Branch 0 taken 1353 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1353 switch(m)
9067 {
9068 case -2:
9069 music_stop();
9070 break;
9071
9072 case -1:
9073 1353 play_DmapMusic();
9074 1353 break;
9075
9076 case 1:
9077 jukebox(ZC_MIDI_OVERWORLD);
9078 break;
9079
9080 case 2:
9081 jukebox(ZC_MIDI_DUNGEON);
9082 break;
9083
9084 case 3:
9085 jukebox(ZC_MIDI_LEVEL9);
9086 break;
9087
9088 default:
9089 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9090 jukebox(m+MIDIOFFSET_MAPSCR);
9091 else
9092 music_stop();
9093 }
9094 1353 }
9095
9096 120 void master_volume(int32_t dv,int32_t mv)
9097 {
9098
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
120 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9099
9100
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
120 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9101
9102
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✓ Branch 5 taken 13 times.
120 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9103 120 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9104 120 }
9105
9106 /*****************/
9107 /***** SFX *****/
9108 /*****************/
9109
9110 // array of voices, one for each sfx sample in the data file
9111 // 0+ = voice #
9112 // -1 = voice not allocated
9113 11 void Z_init_sound()
9114 {
9115
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
9116 2816 sfx_voice[i]=-1;
9117
9118
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 11 times.
88 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9119 77 tunes[i].data = (MIDI*)mididata[i].dat;
9120
9121
2/2
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 11 times.
2783 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9122 2772 tunes[ZC_MIDI_COUNT+j].data=NULL;
9123
9124 11 master_volume(digi_volume,midi_volume);
9125 11 }
9126
9127 // returns number of voices currently allocated
9128 int32_t sfx_count()
9129 {
9130 int32_t c=0;
9131
9132 for(int32_t i=0; i<WAV_COUNT; i++)
9133 if(sfx_voice[i]!=-1)
9134 ++c;
9135
9136 return c;
9137 }
9138
9139 // clean up finished samples
9140 940072 void sfx_cleanup()
9141 {
9142
2/2
✓ Branch 0 taken 240658432 times.
✓ Branch 1 taken 940072 times.
241598504 for(int32_t i=0; i<WAV_COUNT; i++)
9143
4/4
✓ Branch 0 taken 3616490 times.
✓ Branch 1 taken 237041942 times.
✓ Branch 2 taken 3610794 times.
✓ Branch 3 taken 5696 times.
240664128 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9144 {
9145 5696 deallocate_voice(sfx_voice[i]);
9146 5696 sfx_voice[i]=-1;
9147 5696 }
9148 940072 }
9149
9150 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9151 // if a voice is already allocated (and/or playing), then it just returns true
9152 // Returns true: voice is allocated
9153 // false: unsuccessful
9154 121151 bool sfx_init(int32_t index)
9155 {
9156 // check index
9157
3/4
✓ Branch 0 taken 113472 times.
✓ Branch 1 taken 7679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113472 times.
121151 if(index<=0 || index>=WAV_COUNT)
9158 7679 return false;
9159
9160
2/2
✓ Branch 0 taken 105261 times.
✓ Branch 1 taken 8211 times.
113472 if(sfx_voice[index]==-1)
9161 {
9162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8211 times.
8211 if(sfxdat)
9163 {
9164 if(index<Z35)
9165 {
9166 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9167 }
9168 else
9169 {
9170 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9171 }
9172 }
9173 else
9174 {
9175 8211 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9176 }
9177
9178 8211 voice_set_volume(sfx_voice[index], sfx_volume);
9179 8211 }
9180
9181 113472 return sfx_voice[index] != -1;
9182 121151 }
9183
9184 // plays an sfx sample
9185 92409 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9186 {
9187
2/2
✓ Branch 0 taken 88620 times.
✓ Branch 1 taken 3789 times.
92409 if(!sfx_init(index))
9188 3789 return;
9189
9190 88620 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9191 88620 voice_set_pan(sfx_voice[index],pan);
9192
9193 88620 int32_t pos = voice_get_position(sfx_voice[index]);
9194
9195
2/2
✓ Branch 0 taken 42579 times.
✓ Branch 1 taken 46041 times.
88620 if(restart) voice_set_position(sfx_voice[index],0);
9196
9197
2/2
✓ Branch 0 taken 49464 times.
✓ Branch 1 taken 39156 times.
88620 if(pos<=0)
9198 49464 voice_start(sfx_voice[index]);
9199 92409 }
9200
9201 // true if sfx is allocated
9202 2 bool sfx_allocated(int32_t index)
9203 {
9204
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9205 }
9206
9207 // start it (in loop mode) if it's not already playing,
9208 // otherwise adjust it to play in loop mode -DD
9209 28742 void cont_sfx(int32_t index)
9210 {
9211
2/2
✓ Branch 0 taken 3890 times.
✓ Branch 1 taken 24852 times.
28742 if(!sfx_init(index))
9212 {
9213 3890 return;
9214 }
9215
9216
2/2
✓ Branch 0 taken 1555 times.
✓ Branch 1 taken 23297 times.
24852 if(voice_get_position(sfx_voice[index])<=0)
9217 {
9218 1555 voice_set_position(sfx_voice[index],0);
9219 1555 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9220 1555 voice_start(sfx_voice[index]);
9221 1555 }
9222 else
9223 {
9224 23297 adjust_sfx(index, 128, true);
9225 }
9226 28742 }
9227
9228 // adjust parameters while playing
9229 23845 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9230 {
9231
5/6
✓ Branch 0 taken 23526 times.
✓ Branch 1 taken 319 times.
✓ Branch 2 taken 23526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23339 times.
✓ Branch 5 taken 187 times.
23845 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9232 506 return;
9233
9234 23339 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9235 23339 voice_set_pan(sfx_voice[index],pan);
9236 23845 }
9237
9238 // pauses a voice
9239 124 void pause_sfx(int32_t index)
9240 {
9241
4/6
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 120 times.
124 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9242 4 voice_stop(sfx_voice[index]);
9243 124 }
9244
9245 // resumes a voice
9246 62 void resume_sfx(int32_t index)
9247 {
9248
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9249 voice_start(sfx_voice[index]);
9250 62 }
9251
9252 // pauses all active voices
9253 2 void pause_all_sfx()
9254 {
9255
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i=0; i<WAV_COUNT; i++)
9256
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2 times.
514 if(sfx_voice[i]!=-1)
9257 2 voice_stop(sfx_voice[i]);
9258 2 }
9259
9260 // resumes all paused voices
9261 1 void resume_all_sfx()
9262 {
9263
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9264
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(sfx_voice[i]!=-1)
9265 voice_start(sfx_voice[i]);
9266 1 }
9267
9268 // stops an sfx and deallocates the voice
9269 731208 void stop_sfx(int32_t index)
9270 {
9271
3/4
✓ Branch 0 taken 728715 times.
✓ Branch 1 taken 2493 times.
✓ Branch 2 taken 728715 times.
✗ Branch 3 not taken.
731208 if(index<=0 || index>=WAV_COUNT)
9272 2493 return;
9273
9274
2/2
✓ Branch 0 taken 1962 times.
✓ Branch 1 taken 726753 times.
728715 if(sfx_voice[index]!=-1)
9275 {
9276 1962 deallocate_voice(sfx_voice[index]);
9277 1962 sfx_voice[index]=-1;
9278 1962 }
9279 731208 }
9280
9281 // Stops SFX played by Hero's item of the given family
9282 4244 void stop_item_sfx(int32_t family)
9283 {
9284 4244 int32_t id=current_item_id(family);
9285
9286
2/2
✓ Branch 0 taken 4172 times.
✓ Branch 1 taken 72 times.
4244 if(id<0)
9287 4172 return;
9288
9289 72 stop_sfx(itemsbuf[id].usesound);
9290 4244 }
9291
9292 228 void kill_sfx()
9293 {
9294
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 228 times.
58596 for(int32_t i=0; i<WAV_COUNT; i++)
9295
2/2
✓ Branch 0 taken 57832 times.
✓ Branch 1 taken 536 times.
58904 if(sfx_voice[i]!=-1)
9296 {
9297 536 deallocate_voice(sfx_voice[i]);
9298 536 sfx_voice[i]=-1;
9299 536 }
9300 228 }
9301
9302 83119 int32_t pan(int32_t x)
9303 {
9304
1/4
✓ Branch 0 taken 83119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83119 switch(pan_style)
9305 {
9306 case 0:
9307 return 128;
9308
9309 case 1:
9310 83119 return vbound((x>>1)+68,0,255);
9311
9312 case 2:
9313 return vbound(((x*3)>>2)+36,0,255);
9314 }
9315
9316 return vbound(x,0,255);
9317 83119 }
9318
9319 /*******************************/
9320 /******* Input Handlers ********/
9321 /*******************************/
9322
9323 1519858 bool joybtn(int32_t b)
9324 {
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1519858 times.
1519858 if(b == 0)
9326 return false;
9327
9328 1519858 return joy[joystick_index].button[b-1].b !=0;
9329 1519858 }
9330
9331 const char* joybtn_name(int32_t b)
9332 {
9333 if(b == 0)
9334 return "";
9335
9336 return joy[joystick_index].button[b-1].name;
9337 }
9338
9339 int32_t next_press_key()
9340 {
9341 return readkey()>>8;
9342 }
9343
9344 int32_t next_press_btn()
9345 {
9346 clear_keybuf();
9347 /*bool b[joy[joystick_index].num_buttons+1];
9348
9349 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9350 b[i]=joybtn(i);*/
9351
9352 //first, we need to wait until they're pressing no buttons
9353 for(;;)
9354 {
9355 if(keypressed())
9356 {
9357 switch(readkey()>>8)
9358 {
9359 case KEY_ESC:
9360 return -1;
9361
9362 case KEY_SPACE:
9363 return 0;
9364 }
9365 }
9366
9367 poll_joystick();
9368 bool done = true;
9369
9370 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9371 {
9372 if(joybtn(i)) done = false;
9373 }
9374
9375 if(done) break;
9376 rest(1);
9377 }
9378
9379 //now, we need to wait for them to press any button
9380 for(;;)
9381 {
9382 if(keypressed())
9383 {
9384 switch(readkey()>>8)
9385 {
9386 case KEY_ESC:
9387 return -1;
9388
9389 case KEY_SPACE:
9390 return 0;
9391 }
9392 }
9393
9394 poll_joystick();
9395
9396 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9397 {
9398 if(joybtn(i)) return i;
9399 }
9400 rest(1);
9401 }
9402 }
9403
9404 static bool rButton(bool(proc)(),bool &flag)
9405 {
9406 if(!proc())
9407 {
9408 flag=false;
9409 }
9410 else if(!flag)
9411 {
9412 flag=true;
9413 return true;
9414 }
9415
9416 return false;
9417 }
9418
9419 18406481 static bool rButton(bool &btn, bool &flag)
9420 {
9421
2/2
✓ Branch 0 taken 725076 times.
✓ Branch 1 taken 17681405 times.
18406481 if(!btn)
9422 {
9423 17681405 flag=false;
9424 17681405 }
9425
2/2
✓ Branch 0 taken 36533 times.
✓ Branch 1 taken 688543 times.
725076 else if(!flag)
9426 {
9427 36533 flag=true;
9428 36533 return true;
9429 }
9430
9431 18369948 return false;
9432 18406481 }
9433 619 static bool rButtonPeek(bool btn, bool flag)
9434 {
9435
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9436 {
9437 583 return false;
9438 }
9439
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9440 {
9441 9 return true;
9442 }
9443
9444 27 return false;
9445 619 }
9446
9447 // Updated only by keyboard/gamepad.
9448 // If in replay mode, this is set directly by the replay system.
9449 // This should never be read from directly - use control_state instead.
9450 bool raw_control_state[ZC_CONTROL_STATES]=
9451 {
9452 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9453 };
9454
9455 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9456 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9457 // lasts until the next call to load_control_state.
9458 bool control_state[ZC_CONTROL_STATES]=
9459 {
9460 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9461 };
9462
9463 bool disable_control[ZC_CONTROL_STATES]=
9464 {
9465 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9466 };
9467
9468 bool drunk_toggle_state[11]=
9469 {
9470 false, false, false, false, false, false, false, false, false, false, false
9471 };
9472
9473 bool disabledKeys[127]=
9474 {
9475 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9476 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9477 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9478 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9479 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9480 false,false,false,false,false,false,false
9481 };
9482
9483 bool KeyInput[127]=
9484 {
9485 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9486 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9487 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9488 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9489 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9490 false,false,false,false,false,false,false
9491 };
9492
9493 bool KeyPress[127]=
9494 {
9495 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9496 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9497 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9498 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9499 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9500 false,false,false,false,false,false,false
9501 };
9502
9503 bool key_current_frame[127];
9504 bool key_previous_frame[127];
9505
9506 static bool key_system[127];
9507 static bool key_system_previous[127];
9508 static bool key_system_press[127];
9509
9510 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9511 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9512
9513 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9514 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9515 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9516 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9517 #define STICK_PRECISION 56 //define your own sensitivity
9518
9519 738187 void load_control_state()
9520 {
9521
1/2
✓ Branch 0 taken 738187 times.
✗ Branch 1 not taken.
738187 if (!replay_is_replaying())
9522 {
9523 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9524 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9525 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9526 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9527 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9528 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9529 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9530 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9531 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9532 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9533 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9534 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9535 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9536 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9537
9538 if(num_joysticks != 0)
9539 {
9540 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9541 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9542 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9543 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9544 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9545 }
9546 else
9547 {
9548 raw_control_state[14] = false;
9549 raw_control_state[15] = false;
9550 raw_control_state[16] = false;
9551 raw_control_state[17] = false;
9552 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9553 }
9554 }
9555
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 738184 times.
738187 if (replay_is_active())
9556 {
9557
2/2
✓ Branch 0 taken 512475 times.
✓ Branch 1 taken 225709 times.
738184 if (replay_get_version() < 3)
9558 512475 replay_poll();
9559
3/4
✓ Branch 0 taken 225709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 216266 times.
225709 else if (replay_is_replaying() && replay_get_version() < 6)
9560 216266 replay_peek_input();
9561 738184 }
9562
9563 // Some test replay files were made before a serious input bug was fixed, so instead
9564 // of re-doing them or tossing them out, just check for that zplay version.
9565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738181 times.
738187 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9566
2/2
✓ Branch 0 taken 738181 times.
✓ Branch 1 taken 13287258 times.
14025439 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9567 {
9568 13287258 control_state[i] = raw_control_state[i];
9569
4/4
✓ Branch 0 taken 11093058 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 583282 times.
✓ Branch 3 taken 10509776 times.
13287258 if(!botched_input && !control_state[i])
9570 10509776 down_control_states[i] = false;
9571 13287258 }
9572
9573 738181 button_press[0]=rButton(control_state[0],button_hold[0]);
9574 738181 button_press[1]=rButton(control_state[1],button_hold[1]);
9575 738181 button_press[2]=rButton(control_state[2],button_hold[2]);
9576 738181 button_press[3]=rButton(control_state[3],button_hold[3]);
9577 738181 button_press[4]=rButton(control_state[4],button_hold[4]);
9578 738181 button_press[5]=rButton(control_state[5],button_hold[5]);
9579 738181 button_press[6]=rButton(control_state[6],button_hold[6]);
9580 738181 button_press[7]=rButton(control_state[7],button_hold[7]);
9581 738181 button_press[8]=rButton(control_state[8],button_hold[8]);
9582 738181 button_press[9]=rButton(control_state[9],button_hold[9]);
9583 738181 button_press[10]=rButton(control_state[10],button_hold[10]);
9584 738181 button_press[11]=rButton(control_state[11],button_hold[11]);
9585 738181 button_press[12]=rButton(control_state[12],button_hold[12]);
9586 738181 button_press[13]=rButton(control_state[13],button_hold[13]);
9587 738181 button_press[14]=rButton(control_state[14],button_hold[14]);
9588 738181 button_press[15]=rButton(control_state[15],button_hold[15]);
9589 738181 button_press[16]=rButton(control_state[16],button_hold[16]);
9590 738181 button_press[17]=rButton(control_state[17],button_hold[17]);
9591 738181 }
9592
9593 // Returns true if any game key is pressed. This is needed because keypressed()
9594 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9595 3428184 bool zc_key_pressed()
9596 //may also need to use zc_getrawkey
9597 {
9598
7/10
✓ Branch 0 taken 2692319 times.
✓ Branch 1 taken 735865 times.
✓ Branch 2 taken 735865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 735865 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612414 times.
✓ Branch 7 taken 612414 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 148556 times.
3576740 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9599
4/6
✓ Branch 0 taken 612414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612414 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436508 times.
✓ Branch 5 taken 436508 times.
612414 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9600
4/6
✓ Branch 0 taken 436508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 234356 times.
✓ Branch 5 taken 234356 times.
436508 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9601
4/6
✓ Branch 0 taken 234356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 172887 times.
✓ Branch 5 taken 172887 times.
234356 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9602
1/2
✓ Branch 0 taken 172887 times.
✗ Branch 1 not taken.
172887 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9603
3/4
✓ Branch 0 taken 156795 times.
✓ Branch 1 taken 16092 times.
✓ Branch 2 taken 156795 times.
✗ Branch 3 not taken.
172887 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9604
3/4
✓ Branch 0 taken 149613 times.
✓ Branch 1 taken 7182 times.
✓ Branch 2 taken 149613 times.
✗ Branch 3 not taken.
156795 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9605
3/4
✓ Branch 0 taken 149180 times.
✓ Branch 1 taken 433 times.
✓ Branch 2 taken 149180 times.
✗ Branch 3 not taken.
149613 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9606
3/4
✓ Branch 0 taken 148603 times.
✓ Branch 1 taken 577 times.
✓ Branch 2 taken 148603 times.
✗ Branch 3 not taken.
149180 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9607
3/4
✓ Branch 0 taken 148556 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148603 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9608
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9609
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9610
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9611
1/2
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
148556 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9612 6191958 return true;
9613
9614 148556 return false;
9615 955876 }
9616
9617 14917847 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9618 {
9619 14917847 bool ret = false, drunkstate = false;
9620 14917847 bool* flag = &down_control_states[btn];
9621
2/7
✓ Branch 0 taken 13960764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 957083 times.
14917847 switch(btn)
9622 {
9623 case btnF12:
9624 ret = zc_getkey(KEY_F12, ignoreDisable);
9625 eatEntirely = false;
9626 break;
9627 case btnF11:
9628 ret = zc_getkey(KEY_F11, ignoreDisable);
9629 eatEntirely = false;
9630 break;
9631 case btnF5:
9632 ret = zc_getkey(KEY_F5, ignoreDisable);
9633 eatEntirely = false;
9634 break;
9635 case btnQ:
9636 ret = zc_getkey(KEY_Q, ignoreDisable);
9637 eatEntirely = false;
9638 break;
9639 case btnI:
9640 ret = zc_getkey(KEY_I, ignoreDisable);
9641 eatEntirely = false;
9642 break;
9643 case btnM:
9644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 957083 times.
957083 if(FFCore.kb_typing_mode) return false;
9645 957083 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9646 957083 eatEntirely = false;
9647 957083 break;
9648 default: //control_state[] index
9649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13960764 times.
13960764 if(FFCore.kb_typing_mode) return false;
9650
5/6
✓ Branch 0 taken 13942739 times.
✓ Branch 1 taken 18025 times.
✓ Branch 2 taken 237289 times.
✓ Branch 3 taken 13705450 times.
✓ Branch 4 taken 237289 times.
✗ Branch 5 not taken.
13960764 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9651
2/2
✓ Branch 0 taken 743042 times.
✓ Branch 1 taken 13217722 times.
13960764 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9652
4/4
✓ Branch 0 taken 12380357 times.
✓ Branch 1 taken 1580407 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 1580010 times.
15541171 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9653 13960764 }
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14917847 times.
14917847 assert(flag);
9655
2/2
✓ Branch 0 taken 9798005 times.
✓ Branch 1 taken 5119842 times.
14917847 if(press)
9656 {
9657
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 5119223 times.
5119842 if(peek)
9658 619 ret = rButtonPeek(ret, *flag);
9659 5119223 else ret = rButton(ret, *flag);
9660 5119842 }
9661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14917847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14917847 if(eatEntirely && ret) control_state[btn] = false;
9662
3/4
✓ Branch 0 taken 11610645 times.
✓ Branch 1 taken 3307202 times.
✓ Branch 2 taken 11610645 times.
✗ Branch 3 not taken.
14917847 if(drunk && drunkstate) ret = !ret;
9663 14917847 return ret;
9664 14917847 }
9665
9666 8056 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9667 {
9668 8056 byte ret = 0;
9669
2/2
✓ Branch 0 taken 7437 times.
✓ Branch 1 taken 619 times.
8056 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9670
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9671
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9672
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9673
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9674
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9675
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9676
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9677 8056 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9678 }
9679
9680 byte checkIntBtnVal(byte intbtn, byte vals)
9681 {
9682 return intbtn&vals;
9683 }
9684
9685 146363 bool Up()
9686 {
9687 146363 return getInput(btnUp);
9688 }
9689 2426 bool Down()
9690 {
9691 2426 return getInput(btnDown);
9692 }
9693 4170 bool Left()
9694 {
9695 4170 return getInput(btnLeft);
9696 }
9697 4741 bool Right()
9698 {
9699 4741 return getInput(btnRight);
9700 }
9701 8090 bool cAbtn()
9702 {
9703 8090 return getInput(btnA);
9704 }
9705 26096 bool cBbtn()
9706 {
9707 26096 return getInput(btnB);
9708 }
9709 bool cSbtn()
9710 {
9711 return getInput(btnS);
9712 }
9713 296 bool cLbtn()
9714 {
9715 296 return getInput(btnL);
9716 }
9717 296 bool cRbtn()
9718 {
9719 296 return getInput(btnR);
9720 }
9721 bool cPbtn()
9722 {
9723 return getInput(btnP);
9724 }
9725 bool cEx1btn()
9726 {
9727 return getInput(btnEx1);
9728 }
9729 bool cEx2btn()
9730 {
9731 return getInput(btnEx2);
9732 }
9733 bool cEx3btn()
9734 {
9735 return getInput(btnEx3);
9736 }
9737 bool cEx4btn()
9738 {
9739 return getInput(btnEx4);
9740 }
9741 bool AxisUp()
9742 {
9743 return getInput(btnAxisUp);
9744 }
9745 bool AxisDown()
9746 {
9747 return getInput(btnAxisDown);
9748 }
9749 bool AxisLeft()
9750 {
9751 return getInput(btnAxisLeft);
9752 }
9753 bool AxisRight()
9754 {
9755 return getInput(btnAxisRight);
9756 }
9757
9758 bool cMbtn()
9759 {
9760 return getInput(btnM);
9761 }
9762 bool cF12()
9763 {
9764 return getInput(btnF12);
9765 }
9766 bool cF11()
9767 {
9768 return getInput(btnF11);
9769 }
9770 bool cF5()
9771 {
9772 return getInput(btnF5);
9773 }
9774 bool cQ()
9775 {
9776 return getInput(btnQ);
9777 }
9778 bool cI()
9779 {
9780 return getInput(btnI);
9781 }
9782
9783 4381 bool rUp()
9784 {
9785 4381 return getInput(btnUp, true);
9786 }
9787 4371 bool rDown()
9788 {
9789 4371 return getInput(btnDown, true);
9790 }
9791 4370 bool rLeft()
9792 {
9793 4370 return getInput(btnLeft, true);
9794 }
9795 4330 bool rRight()
9796 {
9797 4330 return getInput(btnRight, true);
9798 }
9799 72 bool rAbtn()
9800 {
9801 72 return getInput(btnA, true);
9802 }
9803 4453 bool rBbtn()
9804 {
9805 4453 return getInput(btnB, true);
9806 }
9807 735402 bool rSbtn()
9808 {
9809 735402 return getInput(btnS, true);
9810 }
9811 955876 bool rMbtn()
9812 {
9813 955876 return getInput(btnM, true);
9814 }
9815 4320 bool rLbtn()
9816 {
9817 4320 return getInput(btnL, true);
9818 }
9819 4320 bool rRbtn()
9820 {
9821 4320 return getInput(btnR, true);
9822 }
9823 731084 bool rPbtn()
9824 {
9825 731084 return getInput(btnP, true);
9826 }
9827 bool rEx1btn()
9828 {
9829 return getInput(btnEx1, true);
9830 }
9831 bool rEx2btn()
9832 {
9833 return getInput(btnEx2, true);
9834 }
9835 4320 bool rEx3btn()
9836 {
9837 4320 return getInput(btnEx3, true);
9838 }
9839 4320 bool rEx4btn()
9840 {
9841 4320 return getInput(btnEx4, true);
9842 }
9843 bool rAxisUp()
9844 {
9845 return getInput(btnAxisUp, true);
9846 }
9847 bool rAxisDown()
9848 {
9849 return getInput(btnAxisDown, true);
9850 }
9851 bool rAxisLeft()
9852 {
9853 return getInput(btnAxisLeft, true);
9854 }
9855 bool rAxisRight()
9856 {
9857 return getInput(btnAxisRight, true);
9858 }
9859
9860 bool rF11()
9861 {
9862 return getInput(btnF11, true);
9863 }
9864 bool rQ()
9865 {
9866 return getInput(btnQ, true);
9867 }
9868 bool rI()
9869 {
9870 return getInput(btnI, true);
9871 }
9872
9873 1936178 bool DrunkUp()
9874 {
9875 1936178 return getInput(btnUp, false, true);
9876 }
9877 1790757 bool DrunkDown()
9878 {
9879 1790757 return getInput(btnDown, false, true);
9880 }
9881 1177450 bool DrunkLeft()
9882 {
9883 1177450 return getInput(btnLeft, false, true);
9884 }
9885 1033618 bool DrunkRight()
9886 {
9887 1033618 return getInput(btnRight, false, true);
9888 }
9889 840232 bool DrunkcAbtn()
9890 {
9891 840232 return getInput(btnA, false, true);
9892 }
9893 731857 bool DrunkcBbtn()
9894 {
9895 731857 return getInput(btnB, false, true);
9896 }
9897 730781 bool DrunkcEx1btn()
9898 {
9899 730781 return getInput(btnEx1, false, true);
9900 }
9901 730781 bool DrunkcEx2btn()
9902 {
9903 730781 return getInput(btnEx2, false, true);
9904 }
9905 bool DrunkcSbtn()
9906 {
9907 return getInput(btnS, false, true);
9908 }
9909 bool DrunkcMbtn()
9910 {
9911 return getInput(btnM, false, true);
9912 }
9913 bool DrunkcLbtn()
9914 {
9915 return getInput(btnL, false, true);
9916 }
9917 bool DrunkcRbtn()
9918 {
9919 return getInput(btnR, false, true);
9920 }
9921 bool DrunkcPbtn()
9922 {
9923 return getInput(btnP, false, true);
9924 }
9925
9926 bool DrunkrUp()
9927 {
9928 return getInput(btnUp, true, true);
9929 }
9930 bool DrunkrDown()
9931 {
9932 return getInput(btnDown, true, true);
9933 }
9934 bool DrunkrLeft()
9935 {
9936 return getInput(btnLeft, true, true);
9937 }
9938 bool DrunkrRight()
9939 {
9940 return getInput(btnRight, true, true);
9941 }
9942 587483 bool DrunkrAbtn()
9943 {
9944 587483 return getInput(btnA, true, true);
9945 }
9946 589544 bool DrunkrBbtn()
9947 {
9948 589544 return getInput(btnB, true, true);
9949 }
9950 bool DrunkrEx1btn()
9951 {
9952 return getInput(btnEx1, true, true);
9953 }
9954 bool DrunkrEx2btn()
9955 {
9956 return getInput(btnEx2, true, true);
9957 }
9958 bool DrunkrEx3btn()
9959 {
9960 return getInput(btnEx3, true, true);
9961 }
9962 bool DrunkrEx4btn()
9963 {
9964 return getInput(btnEx4, true, true);
9965 }
9966 bool DrunkrSbtn()
9967 {
9968 return getInput(btnS, true, true);
9969 }
9970 bool DrunkrMbtn()
9971 {
9972 return getInput(btnM, true, true);
9973 }
9974 730788 bool DrunkrLbtn()
9975 {
9976 730788 return getInput(btnL, true, true);
9977 }
9978 730557 bool DrunkrRbtn()
9979 {
9980 730557 return getInput(btnR, true, true);
9981 }
9982 bool DrunkrPbtn()
9983 {
9984 return getInput(btnP, true, true);
9985 }
9986
9987 1207 void eat_buttons()
9988 {
9989 1207 getInput(btnA, true, false, true);
9990 1207 getInput(btnB, true, false, true);
9991 1207 getInput(btnS, true, false, true);
9992 1207 getInput(btnM, true, false, true);
9993 1207 getInput(btnL, true, false, true);
9994 1207 getInput(btnR, true, false, true);
9995 1207 getInput(btnP, true, false, true);
9996 1207 getInput(btnEx1, true, false, true);
9997 1207 getInput(btnEx2, true, false, true);
9998 1207 getInput(btnEx3, true, false, true);
9999 1207 getInput(btnEx4, true, false, true);
10000 1207 }
10001
10002 // Is true for the _first frame_ of a key press.
10003 // But! it is possible that a script manually sets the value of KeyPress,
10004 // in which case it will be restored to the "true" value based on `key_current_frame`
10005 // and `key_previous_frame` on the next frame.
10006 1 bool zc_readkey(int32_t k, bool ignoreDisable)
10007 {
10008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
10009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
10010 {
10011 case KEY_F7:
10012 case KEY_F8:
10013 case KEY_F9:
10014 return KeyPress[k];
10015
10016 default:
10017
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
10018 }
10019 1 }
10020
10021 // Is true for _every frame_ a key is held down.
10022 // But! it is possible that a script manually sets the value of KeyInput,
10023 // in which case it will be restored to the "true" value based on `key_current_frame`
10024 // on the next frame.
10025 bool zc_getkey(int32_t k, bool ignoreDisable)
10026 {
10027 if(ignoreDisable) return KeyInput[k];
10028 switch(k)
10029 {
10030 case KEY_F7:
10031 case KEY_F8:
10032 case KEY_F9:
10033 return KeyInput[k];
10034
10035 default:
10036 return KeyInput[k] && !disabledKeys[k];
10037 }
10038 }
10039
10040 // Reads (and then clears) the current frame key state directly.
10041 // Scripts can also modify `key_current_frame`.
10042 124831 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10043 {
10044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124831 times.
124831 if(zc_getrawkey(k, ignoreDisable))
10045 {
10046 _key[k]=key[k]=key_current_frame[k]=0;
10047 return true;
10048 }
10049 124831 _key[k]=key[k]=key_current_frame[k]=0;
10050 124831 return false;
10051 124831 }
10052
10053 // Reads the current frame key state directly.
10054 // Scripts can also modify `key_current_frame`.
10055 5428235 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10056 {
10057
2/2
✓ Branch 0 taken 4347529 times.
✓ Branch 1 taken 1080706 times.
5428235 if(ignoreDisable) return key_current_frame[k];
10058
2/2
✓ Branch 0 taken 124828 times.
✓ Branch 1 taken 955878 times.
1080706 switch(k)
10059 {
10060 case KEY_F7:
10061 case KEY_F8:
10062 case KEY_F9:
10063 124828 return key_current_frame[k];
10064
10065 default:
10066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955878 times.
955878 return key_current_frame[k] && !disabledKeys[k];
10067 }
10068 5428235 }
10069
10070 // Only used for a handful of keys, like tilde and Function keys.
10071 // This state is never read within the game.
10072 // It exists so that all keyboard input still functions during replay,
10073 // without inadvertently doing things like toggling throttling if the player
10074 // presses ~
10075 940368 bool zc_get_system_key(int32_t k)
10076 {
10077 940368 return key_system[k];
10078 }
10079
10080 // True for the _first_ frame of a key press.
10081 10514636 bool zc_read_system_key(int32_t k)
10082 {
10083 10514636 return key_system_press[k];
10084 }
10085
10086 121396252 bool is_system_key(int32_t k)
10087 {
10088
2/2
✓ Branch 0 taken 112793368 times.
✓ Branch 1 taken 8602884 times.
121396252 switch (k)
10089 {
10090 case KEY_BACKQUOTE:
10091 case KEY_CLOSEBRACE:
10092 case KEY_END:
10093 case KEY_HOME:
10094 case KEY_OPENBRACE:
10095 case KEY_PGDN:
10096 case KEY_PGUP:
10097 case KEY_TAB:
10098 case KEY_TILDE:
10099 8602884 return true;
10100 }
10101 112793368 return is_Fkey(k);
10102 121396252 }
10103
10104 955876 void update_system_keys()
10105 {
10106 955876 poll_keyboard();
10107
2/2
✓ Branch 0 taken 121396252 times.
✓ Branch 1 taken 955876 times.
122352128 for (int32_t q = 0; q < 127; ++q)
10108 {
10109
2/2
✓ Branch 0 taken 20073396 times.
✓ Branch 1 taken 101322856 times.
121396252 if (!is_system_key(q))
10110 101322856 continue;
10111
10112 20073396 key_system[q] = key[q];
10113
1/2
✓ Branch 0 taken 20073396 times.
✗ Branch 1 not taken.
20073396 key_system_press[q] = key_system[q] && !key_system_previous[q];
10114 20073396 key_system_previous[q] = key_system[q];
10115 20073396 }
10116 955876 }
10117
10118 940368 void update_keys()
10119 {
10120
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if (!replay_is_replaying())
10121 poll_keyboard();
10122
10123
2/2
✓ Branch 0 taken 940368 times.
✓ Branch 1 taken 119426736 times.
120367104 for (int32_t q = 0; q < 127; ++q)
10124 {
10125 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10126
1/2
✓ Branch 0 taken 119426736 times.
✗ Branch 1 not taken.
119426736 if (!replay_is_replaying())
10127 key_current_frame[q] = key[q];
10128
10129
2/2
✓ Branch 0 taken 118527205 times.
✓ Branch 1 taken 899531 times.
119426736 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10130
3/4
✓ Branch 0 taken 27677 times.
✓ Branch 1 taken 119399059 times.
✓ Branch 2 taken 27677 times.
✗ Branch 3 not taken.
119426736 if (KeyPress[q] && q == KEY_B) {
10131 int lol = 1;
10132 }
10133 119426736 KeyInput[q] = key_current_frame[q];
10134 119426736 key_previous_frame[q] = key_current_frame[q];
10135 119426736 }
10136 940368 }
10137
10138 bool zc_disablekey(int32_t k, bool val)
10139 {
10140 switch(k)
10141 {
10142 case KEY_F7:
10143 case KEY_F8:
10144 case KEY_F9:
10145 return false;
10146
10147 default:
10148 disabledKeys[k] = val;
10149 return true;
10150 }
10151 }
10152
10153 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10154 {
10155 timer=timer;
10156 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10157 }
10158
10159 // these are here so that copy_dialog won't choke when compiling zelda
10160 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10161 {
10162 return D_O_K;
10163 }
10164
10165 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10166 {
10167 return D_O_K;
10168 }
10169
10170 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10171 {
10172 return D_O_K;
10173 }
10174
10175 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10176 {
10177 return D_O_K;
10178 }
10179
10180 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10181 {
10182 return D_O_K;
10183 }
10184
10185 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10186 {
10187 return D_O_K;
10188 }
10189
10190 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10191 {
10192 return D_O_K;
10193 }
10194
10195 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10196 {
10197 return D_O_K;
10198 }
10199
10200 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10201 {
10202 return D_O_K;
10203 }
10204
10205 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10206 {
10207 return D_O_K;
10208 }
10209
10210 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10211 {
10212 return D_O_K;
10213 }
10214
10215 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10216 {
10217 return D_O_K;
10218 }
10219
10220 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10221 {
10222 return D_O_K;
10223 }
10224
10225 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10226 {
10227 return D_O_K;
10228 }
10229
10230 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10231 {
10232 return D_O_K;
10233 }
10234
10235 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10236 {
10237 return D_O_K;
10238 }
10239
10240 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10241 {
10242 return D_O_K;
10243 }
10244
10245 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10246 {
10247 return D_O_K;
10248 }
10249
10250 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10251 {
10252 return D_O_K;
10253 }
10254
10255 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10256 {
10257 return D_O_K;
10258 }
10259
10260 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10261 {
10262 return D_O_K;
10263 }
10264
10265 /*** end of zc_sys.cc ***/
10266
10267